my processing sketch runs fine in appletviewer but not at all running in any browser

m using processing 2. code runs fine without browser but when i export it as applet and trying to run in browser then nothing is displayed nor i got any error. pls help.. its urgent. :(

Answers

  • Answer ✓

    If you expect help with this then you need to provide more information.

    Did you create the sketch in Java mode?

    Are you using any contributed libraries (what import statements do you have)?

    When attempting to display in browser were you using JavaScript mode?

    What were you using to export the applet?

  • edited November 2013 Answer ✓

    Processing 2+ doesn't export as applet anymore!
    For that you either use Processing 1.5.1 or use an existing utility which accomplishes that!

  • Answer ✓

    For Java mode sketches using the default (Java2D) renderer there is the Applet Exporter and Signer tool which works with Processing 2.1

  • yes m using export in java mode with processing 2.0 with applet signer and export tool

  • i have following import statements processing.papplet; processing.pimage;

  • edited November 2013

    Are you using the P2D or P3D renderer?

    If you are working in Processing IDE then the import statements are not required unless you have created your own class in a .java tab, try running your sketch without them.

  • edited November 2013

    m using processing IDE all other apps are running in browser but following code doesnt run in browser nor show any error

    String iName="image.jpg";
    
    void setup() {
      llegeixImatge("./"+iName);
      size(465, 600);
    }
    
    // parameters
    // NO real control, so be careful
    
    int NP=6000; // 1000 for line art, 10000 for complex images, O(N^2) so be patient!!!
    int B=1; // try 2 or 3
    float THR=28; // range 5-50
    float MD=6; // range 0-10
    int NMP=6; // range 1-15
    
    float[][] punts;
    color[] cpunts;
    int [] usat;
    int [] NmP=new int[NMP];
    float [] NdmP=new float[NMP];
    
    int inici=0;
    
    PImage img;
    
    void llegeixImatge(String s) {
      img = loadImage(s);
      img.loadPixels();
    }
    
    float fVar(int x, int y) {
      // neighborhood 2B+1x2B+1 pixels
      float m=0;
      for (int k1=-B; k1<=B; k1++) {
        for (int k2=-B; k2<=B; k2++) {
          color c=img.pixels[(y+k1)*img.width+(x+k2)];
          m+=brightness(c);
    
  • the problem was due to following error in java console. but how to slove it?? The file "./image.jpg" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.

  • There are three things to try

    1) The size() statement should be the first on in setup() so change it to

    void setup() {
      size(465, 600);
      llegeixImatge("./"+iName);
    }
    

    2) You might also try changing line 3 to

    llegeixImatge(iName);

    3) In your sketch folder create a new folder called data and put the image in there.

  • I tried all the above solution but still getting same error in java console that image is missing or inaccessible.

  • edited November 2013

    The solution is

    void setup() {
      size(465, 600);
      llegeixImatge(iName);
    }
    

    and make sure the image is in a folder called data inside the sketch folder.

Sign In or Register to comment.