Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet and getCodeBase problem

 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which object is null?
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i solved this problem by this code line


PlanarImage image = JAI.create("URL",url);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic