I am experimenting with Java Web Start.
I have just written a basic JApplet which has a method on the Applet class called getDocumentBase(). This returns the full URL to the location the Applet is running (under Tomcat) i.e. http://myserver:8080/myapp/whateverapplet.jar.
However, I am looking for something similar with a web start application. I need to know where it is running. Is there anything that can give me this information?
EDIT
In terms of where it is running I mean if I run a web start from a JNLP file I want:
If I run the JAR from a folder on the network I want:
\\server\myapp
Or if I run the JAR from a folder on my machine I want:
D:\myapp
End Edit
I guess you want to get the code base URL from within your running application? If this is the case, you can use this snippet:
Note that you’ll have to depend on the JNLP API to compile this code (for the
BasicServiceclass).