• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Appletviewer runs applet in current dir only

 
merlin bar
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I'm in the same directory as TestApplet.html, appletviewer runs it no problem, but it wont run it if I go up a directory and do..

Equally, if I give appletviewer a full path it says:

Ultimately, the applet isnt running on my site, but runs on appletviewer (under the above conditions). I think this is the reason.
Heres the exception...

Can anyone help?
Regards,
merlin_bar
[ December 14, 2003: Message edited by: merlin bar ]
 
merlin bar
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have narrowed this down. It is the method I use to load images that causes the problem.
This runs from any location, but only works for applications:

The following on the other hand. will only execute from the current dir, but works for both applications and applets.

I'm stuck between a rock and a hard place here. If it were just an application, it woulc be okay, but I want to use the component for applets too.
I need it to run from any location. (prerequeset of my host).
If anyone has any ideas, I appreciate it as always.

Thankyou for your time,
merlin_bar
 
Ban Bala
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I encountered such problem, I added the .java.policy under the home directory(eg: c:\winint\profiles\<your id>.
The following line in the policy file solved my problem
permission java.io.FilePermission "<<ALL FILES>>", "read";
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the image in a .jar file (Ant is quite handy for doing this) with all of your other code then use something like:
String imageToLoad = "images/tank_bothValvesClosed.png";
URL url = YourClassNameHere.class.getResource(imageToLoad);
Image theimage=Toolkit.getDefaultToolkit().getImage(url);
this works for applets or applications
 
merlin bar
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou both. Brian, that worked for me! I didnt have to put the images in a jar file however.
Thanks again, I couldnt go any further untill this part was working.
Regards,
merlin
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you don't HAVE to put them in a jar, but if you are going to deploy your app, putting it in a jar makes a lot of sense and if you're going to jar it up eventually, you may as well get that part working sooner rather than later.
Does that win any run-on sentence awards?
Brian
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic