wood burning stoves 2.0*
The moose likes Applets and the fly likes applet and getCodeBase 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 "applet and getCodeBase problem" Watch "applet and getCodeBase problem" New topic
Author

applet and getCodeBase problem

hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
hi

i am trying to get TIF file from server to open it in applet and make some changing and send back to server

this my part of my code makes problem.

String fileName = "uma.tif";
String path =getCodeBase()+fileName;
PlanarImage image = JAI.create("fileload",path);


at this line i got this Exception.


java.lang.IllegalArgumentException: "http://localhost/loly/uma.tif": File not found.
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:1412)
at tiff4.init(tiff4.java:54)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


while this file in this place , and this applet signed
how can i get this file from server and send it back does any body
knows how can i do it ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
I'm no expert on JAI, but I don't think it can handle URLs.

You could use the javax.imageio.ImageIO.read(URL) method to obtain a BufferedImage from an URL. I'm sure JAI has methods that can accept a BufferedImage.

ImageIO doesn't handle TIFFs out of the box, but it looks as if JAI adds a TIFF plugin for ImageIO, so you should be all set.
[ April 20, 2008: Message edited by: Ulf Dittmer ]

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

Joined: Apr 23, 2006
Posts: 127
sorry

i have tryied that
String path =getCodeBase()+fileName;
URL H=new URL(path);
BufferedImage bi=ImageIO.read(H);
Graphics2D big = bi.createGraphics();
big.setFont(new Font("Dialog", Font.PLAIN, 10));
big.setColor(Color.black);
big.drawString("BufferedImage", 100, 12);


AND I GOT THIS

java.lang.NullPointerException
at tiff4.init(tiff4.java:62)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Which object is null?
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
i solved this problem by this code line


PlanarImage image = JAI.create("URL",url);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: applet and getCodeBase problem