• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Appletviewer runs applet in current dir only

 
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
 
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";
 
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
 
Screaming fools! It's nothing more than a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic