aspose file tools*
The moose likes Applets and the fly likes JAI with applet problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "JAI with applet problem" Watch "JAI with applet problem" New topic
Author

JAI with applet problem

hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
I have write applet that can write TIFF file all steps are fine ,except final step before writing

RenderedOp op = JAI.create("filestore", image3,filename2, format2);

at this comand , I got Process completed when compiling
when i try to run applet i got (notinited)

i signed my applet but same situation
when i remove this line it compil will and run will without writing my file !!!
what wrong with this line i need to write my file.

i opend console I found this error.




java.lang.NoClassDefFoundError: javax/media/jai/JAI
at readFileApplet.readFile(readFileApplet.java:93)
at readFileApplet.init(readFileApplet.java:55)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.jai.JAI
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 4 more
Caused by: java.io.FileNotFoundException: C:\iamge\javax\media\jai\JAI.class (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 9 more
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
I'd say the applet tag doesn't properly reference the codebase or the archives it uses. Do you really have a directory called "C:\iamge"?

It would help if you showed us the applet tag.


Ping & DNS - my free Android networking tools app
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
thanks

this applet tag

<APPLET CODE = readFileApplet.class ARCHIVE=readFileApplet.jar WIDTH = "100%" HEIGHT = "100%">
</APPLET>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
You will definitely need to sign the applet, otherwise it's not allowed to perform file I/O.

What are the values of the parameters you're passing, particularly filename2 and format2?

Where is the reference to the "iamge" directory coming from?
[ March 29, 2008: Message edited by: Ulf Dittmer ]
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
thanks

I have signed it and i have tried to let applet write file txt it and it work
but still this command does not work

RenderedOp op = JAI.create("filestore", image3,filename2, format2);

i have try to and found this rescource
http://java.sun.com/products/java-media/jai/forDevelopers/jaifaq.html#applet

but still not working
and my browser can not run example that sun have put it ???
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
hi

iamge is the folder where my applet and html files are?
my files name variable put as final for testing only.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
What does "but still not working" mean? Are there any error messages? I just tried that example with Firefox and it worked fine.

By the way, the width and height attributes of the applet tag take pixels as values, not percentages.
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
not working means

it gives me

that: applet JAIAppletDemo notinited

at status bar i am using IE6
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
And what error message do you get in the Java Console? TellTheDetails
[ March 30, 2008: Message edited by: Ulf Dittmer ]
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
I am using
JDk version6 update 4

i excepect to read and write TIF files using applet
beacuse sun have said that can be happend .

i need it to draw + writing + edit using applet and save this as TIFF file for one off my clients.

i have pring JAI library version jai-1_1_3-lib-windows-i586
and write a demo as simple class and it work i have create TIFF file and write to and edit and insert Image to it .

when i tried to make this happend using applet i start by Create TIFF file and Signed it
all code compile well .
at running it give me applet notinited at status bar
this is error mesasge in consel.

java.lang.NoClassDefFoundError: javax/media/jai/JAI
at readFileApplet.readFile(readFileApplet.java:93)
at readFileApplet.init(readFileApplet.java:55)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.jai.JAI
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 4 more
Caused by: java.io.FileNotFoundException: C:\iamge\javax\media\jai\JAI.class (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 9 more

when i remove this line of code

RenderedOp op = JAI.create("filestore", image3,filename2, format2);

it compile well and applet be initilized and run fine
ofcourse it does not write becouse this line responsbile about writing.

i am working on winxp sp2 and IE6

snip of code
//////////////////////////////////////////////////////
String fileTowrite = "nour.tif";
String format = "TIFF";

BufferedImage jj = new BufferedImage(this.getWidth(),this.getHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics2D g = jj.createGraphics();

g.drawString("Hassan Ali",10,10);
g.dispose();
RenderedImage image3 = jj;
URL filename = new URL(getCodeBase(), fileTowrite);


/////////////////??? this line makes error

RenderedOp op = JAI.create("filestore", image3,filename, format);

////////////////???

here an example at sun site it also does not work
at my browser try it .

http://java.sun.com/products/java-media/jai/forDevelopers/samples/JAIApplet.html
[ March 30, 2008: Message edited by: hassan ali ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
My question was about what happened when you tried to run the applet demo on Sun's site. You can't possibly have gotten the same error message; which one did you get?
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
hi
thanks

when i try sun demo this error message i got it when open console

Java Plug-in 1.6.0_04
Using JRE version 1.6.0_04 Java HotSpot(TM) Client VM
User home directory = D:\Documents and Settings\hasssan

java.lang.NoClassDefFoundError: javax/media/jai/widget/ImageCanvas
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.jai.widget.ImageCanvas
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 10 more
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 15 more
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
Now I see. JAI isn't downloaded by the applet; you need to put it into a location where any JVM can find it. Usually that would be a directory called jre\lib\ext in your Java installation. See this article for more information.
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
thanks
yes this was a problem , and solved sun demo problem but now i have secuirty problem with my applet.

Note I have signed my applet but the message that appere for asking authrization to use resources does not appere

this my steps to create signed jar file

1-keytool -genkey -keystore myKeystore -alias myself
2-keytool -selfcert -alias myself -keystore myKeystore
3-jarsigner -keystore myKeystore Write.jar myself

and this masseage error in java console

java.lang.IllegalArgumentException: FileStore SecurityException encountered in file creation test: access denied (java.io.FilePermission nour.tif read)
at javax.media.jai.JAI.createNS(JAI.java:1091)
at javax.media.jai.JAI.create(JAI.java:977)
at javax.media.jai.JAI.create(JAI.java:1625)
at JAIAppletDemo.start(JAIAppletDemo.java:39)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAI with applet problem