File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 39548
    
  27
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 - updated with new look and Ping home screen widget
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: 39548
    
  27
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);
 
 
subject: applet and getCodeBase problem
 
Similar Threads
Help with JAI
Image Rotation
how to read file into applet in weblogic server
JAI with applet problem
applet access file on his server?