N
Nigel Wade
Hi,
I'm trying to get an applet to load a file from its jar-file. I can do this
by the usual Class.getResource(filename) provided I use an absolute URL for
the codebase in the APPLET tag. However, what I want to do is serve the
HTML from Apache and the jars from Tomcat (the applet read from a servlet
and avoids duplicating the jars in Apache and Tomcat).
If I use codebase="http://www.ion.le.ac.uk:8080/java/lib" in the APPLET tag
then it all works well. However, I'd like to avoid using the hostname in
the URL, i.e. codebase="http://:8080/java/lib". However, this doesn't work.
The jar file is downloaded to the browser and the applet runs, but
getResource(filename) returns null, indicating it couldn't find the
relevent resource/file.
The jarfile in question is called worldMap.jar and contains the class
worldMap.World (i.e. worldMap/World.class). In World.java I use
World.class.getResource("/map_data.i") to load the file /map_data.i from
the jarfile. As I mentioned above if I use an absolute URL for the
classpath it works, but with the hostname omitted from the URL it fails.
Does anyone know what I need to do to get this to work?
The full APPLET tag is:
<applet code="realTimeApplet/StartUp.class"
codebase="http://:8080/java/lib"
archive="realTimeApplet.jar" width="100" height="100">
and the contents of worldMap.jar are:
META-INF/
META-INF/MANIFEST.MF
map_data.i
worldMap/
worldMap/World$LoadFromURL.class
worldMap/World$LoadingMonitor.class
worldMap/World$OutlineGeo.class
worldMap/World$OutlinePath.class
worldMap/World.class
worldMap/WorldMapLoadingException.class
I'm trying to get an applet to load a file from its jar-file. I can do this
by the usual Class.getResource(filename) provided I use an absolute URL for
the codebase in the APPLET tag. However, what I want to do is serve the
HTML from Apache and the jars from Tomcat (the applet read from a servlet
and avoids duplicating the jars in Apache and Tomcat).
If I use codebase="http://www.ion.le.ac.uk:8080/java/lib" in the APPLET tag
then it all works well. However, I'd like to avoid using the hostname in
the URL, i.e. codebase="http://:8080/java/lib". However, this doesn't work.
The jar file is downloaded to the browser and the applet runs, but
getResource(filename) returns null, indicating it couldn't find the
relevent resource/file.
The jarfile in question is called worldMap.jar and contains the class
worldMap.World (i.e. worldMap/World.class). In World.java I use
World.class.getResource("/map_data.i") to load the file /map_data.i from
the jarfile. As I mentioned above if I use an absolute URL for the
classpath it works, but with the hostname omitted from the URL it fails.
Does anyone know what I need to do to get this to work?
The full APPLET tag is:
<applet code="realTimeApplet/StartUp.class"
codebase="http://:8080/java/lib"
archive="realTimeApplet.jar" width="100" height="100">
and the contents of worldMap.jar are:
META-INF/
META-INF/MANIFEST.MF
map_data.i
worldMap/
worldMap/World$LoadFromURL.class
worldMap/World$LoadingMonitor.class
worldMap/World$OutlineGeo.class
worldMap/World$OutlinePath.class
worldMap/World.class
worldMap/WorldMapLoadingException.class