Though not entirely clear from the spec for Applet.getCodeBase() and
AppletContext.getCodeBase(), it seems reasonable to assume that if the class
file for an applet is within a JAR file, then the returned code base should
reference that location. Currently it does not.
FILE: GetCodeBase.java
import java.applet.Applet;
public class GetCodeBase extends Applet {
public void init() {
System.out.println("getCodeBase() = " + getCodeBase());
}
}
FILE: GetCodeBase.html
<html>
<body>
<applet width=100 height=100 code=GetCodeBase.class archive=GetCodeBase.jar>
</applet>
</body>
</html>
OUTPUT:
(iag@ribbit) $ java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-G)
Java HotSpot (TM) Client VM (build 1.3-G, interpreted mode)
(iag@ribbit) $ javac GetCodeBase.java
(iag@ribbit) $ jar cf GetCodeBase.jar GetCodeBase.class
(iag@ribbit) $ rm GetCodeBase.class
(iag@ribbit) $ appletviewer GetCodeBase.html
getCodeBase() = file:/home/iag/work/bug/av/
iris.garcia@eng 1999-09-22