• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getCodeBase() from JApplet question.

 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Quick - and maybe dumb - question. I have a JApplet running from an HTML page - not in a web server (don't ask why is is an applet verses an application - it's a long story... ) It is a signed applet. I would like to find a way to determine what directory this page is launched from. getCodeBase() returns a null and I assume it is because I am not running a web server. Any ideas?
Thanks,

Paul
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getCodeBase() works for me using Java 1.4.2_04 and a browser with Java Plug-In or Appletviewer.
 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, Joe. I added the plugin and it didn't seem to make a difference - I still get a null for the codebase. I need this to work with the user just double clicking on the htmp page - do dependencies on a web server running.

docBase = this.getCodeBase().toString();

I am accesing this within my init() method - does that make a difference? I know that you can't access parameters from within the constructor, but I should be able to see this from init()...

:roll:

PS - I'm using 1.4.2_05
[ August 02, 2004: Message edited by: Paul Smiley ]
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure the plug-in is loading the applet? Look at the java console to see the version. If it's not, go to the Windows Control Panel (start->settings->control panel) and click on the plug-in icon. There's a tab marked "browser" where you can set the plugin to override IE's default vm.
 
Paul Smiley
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, it's running 1.4.2_05 plug in. Not sure why I can't see the codebase. I'm going to fire up Tomcat and launch it from there and see if that works...
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try running the code from this topic. It's what I've been using to validate that getCodeBase() works. This will let us determine if it is your system or your code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic