We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › export to application or web
Page Index Toggle Pages: 1
export to application or web (Read 1169 times)
export to application or web
Feb 7th, 2006, 5:16pm
 
my code uses loadStrings() and has a txt file inside the sketch folder. it runs fine in the processing environment, but when i export it to application or web, the browser says "applet started" and nothing happens. the weird part is that i had a similar code before, which exported well, but trying to re-export the same code form 0103 Beta, it doesn't work. example codes work however, so it's me not my java... i have tried having the txt file in the applet or data folder and have also tried copypasting the text to a new file to avoid read-only issues. no luck so far...an suggestions?

it looks like this:

// Updated Jan 6, 2005**********************

int i; // declare counter
int totSize; // declare the image size indicator
int x;
int y;
int av;

String lines[];
int nrlines;
float [] dataSet;
String Dimensions1[];
int Width;
int Height;


void setup()
{
 size(70, 200);
 //stroke(100);
 framerate(90);
 background(100);

 lines = loadStrings("zz.txt");
 nrlines = lines.length;
 dataSet = new float [nrlines];
 Dimensions1 = split (lines[0]);
 println (lines[0]);
 Width = int (Dimensions1[0]);
 Height = int (Dimensions1[1]);
 
 for(i=1; i<nrlines; i++) {

   String Colors[] =  split (lines[i]); //break up the 3 number line into individual array pieces
   int Red = int (Colors[0]);   // read Red
   int Green = int (Colors[1]);// read Green
   int Blue = int (Colors[2]);// read Blue

   int av = (int) ((Red + Green + Blue)/3.0);  // get the average
   dataSet[i] = 1.0-(av/255.0);   // save the average

 }
 
}

//this is the verticle index ... which line to draw
int start = 0;


void draw()
{


 int k;

 //only drawing one line, so we have a one dimensional loop
 for (x = 0; x < Height  ; x++)
 {
   //this is the index into the data set
   k = start*(Height) + x ;
   y = start;
   stroke(255,0,0);
   if(dataSet[k] > 0) line(Height-x, y, Height-x, (y-(dataSet[k])));
 }

 start++;
 if (start == Width)
 {
 background(100);
 start = 0;

 }

}
Re: export to application or web
Reply #1 - Feb 7th, 2006, 9:44pm
 
Is the text fiel in the sketch folder, or the data folder, inside the sketch folder?

If the former, try creating a directory called data inside your sketch folder, and put the text file in there.

If the latter, then I don't know what's wrong.
Re: export to application or web
Reply #2 - Feb 8th, 2006, 1:31am
 
thanks JohnG, works!
Re: export to application or web
Reply #3 - Aug 4th, 2006, 11:35am
 
I encounter a very similar problem too. I use processing 115 Beta and I used loadImage() in my program to load a jpg image. It works fine inside processing but it results in a white blank screen when it is exported. I then later on convert the color value of that image to a txt file by another processing program and then use loadString() to load the color data into my original program. Again it works inside processing but not in the case of exporting.

I have put the jpg image and the txt file in a "data" folder inside my project folder. my Java folder has the name like "j2re1.4.2_03" so i think it is java 1.4.2

I have checked on the web and it seems that loadImage() may not work well in exporting.  Is there anyway to solve this problem? I am very closed to completing my project, does anyone have insight? Please help.
Re: export to application or web
Reply #4 - Aug 7th, 2006, 11:09am
 
I tried and I think I know a bit more about the problem. I think it is because of the security issue of IE. I can run the applet separately and  load the image successfully, but when I run the applet on IE, I only got a blank screen.

Does anyone know how to set the IE so that it allow applet to be run, particularly the applet of loading image/ text. Please help.
Re: export to application or web
Reply #5 - Aug 7th, 2006, 11:26am
 
The error message I found in Java Console is the following. I hope listing them can help.

java.lang.reflect.InvocationTargetException


at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)


at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)


at java.lang.reflect.Method.invoke(Unknown Source)


at processing.core.PApplet.loadImageIO(PApplet.java:3135)


at processing.core.PApplet.loadImage(PApplet.java:3068)


at sketch_060807a.setup(sketch_060807a.java:1)


at processing.core.PApplet.handleDisplay(PApplet.java:1269)


at processing.core.PGraphics.requestDisplay(PGraphics.java:535)


at processing.core.PApplet.run(PApplet.java:1152)


at java.lang.Thread.run(Unknown Source)

Caused by: javax.imageio.IIOException: Invalid JPEG file structure: SOS before SOF


at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method)


at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(Unknown Source)


at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(Unknown Source)


at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(Unknown Source)


at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(Unknown Source)


at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source)


at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)


at javax.imageio.ImageIO.read(Unknown Source)


at javax.imageio.ImageIO.read(Unknown Source)


... 11 more

Error while running applet.

java.lang.NullPointerException


at processing.core.PGraphics.image(PGraphics.java:1696)


at processing.core.PApplet.image(PApplet.java:6684)


at sketch_060807a.setup(sketch_060807a.java:3)


at processing.core.PApplet.handleDisplay(PApplet.java:1269)


at processing.core.PGraphics.requestDisplay(PGraphics.java:535)


at processing.core.PApplet.run(PApplet.java:1152)


at java.lang.Thread.run(Unknown Source)

java.lang.NullPointerException


at processing.core.PGraphics.image(PGraphics.java:1696)


at processing.core.PApplet.image(PApplet.java:6684)


at sketch_060807a.setup(sketch_060807a.java:3)


at processing.core.PApplet.handleDisplay(PApplet.java:1269)


at processing.core.PGraphics.requestDisplay(PGraphics.java:535)


at processing.core.PApplet.run(PApplet.java:1152)


at java.lang.Thread.run(Unknown Source)

Re: export to application or web
Reply #6 - Aug 7th, 2006, 1:21pm
 
my guess is that 1.4.2_03 has a bug that doesn't like that type of jpeg file. java 1.4.2_10, which is included with processing, may not have the bug. i would uninstall any older versions of java, restart, and then install the latest 1.4.2 release that's available.
Re: export to application or web
Reply #7 - Aug 8th, 2006, 8:57am
 
Thanks a lot, Fry. I installed jre-1_5_0_07 and my applet eventually works.

At the begining the applet actually still failed to display but I repeated to export for several times and it finally worked. quite strange.

anyway, I cam almost complete my project now. It is really good.

Re: export to application or web
Reply #8 - Aug 8th, 2006, 1:16pm
 
the failure to display is an odd linux issue:
http://dev.processing.org/bugs/show_bug.cgi?id=282
that i believe has been fixed for 0116.
Page Index Toggle Pages: 1