Setting codebase for applets

Pavel Roskin pavel_roskin at geocities.com
Wed Jun 16 02:41:26 PDT 1999


Hello!

The attached patch makes Javanoid
http://webhome.infonie.fr/rfaitout/index.htm
work again (now with sound!)

The Kaffe's appletviewer will now try to set codebase to the current
directory with "file:" prepended. This is how JDK does it.

I personally don't like this code very much, since it will most likely
work incorrectly on "other OS'es". Feel free to write it better. It is
perhaps java.net.URL which should be improved.

Nevertheless it is IMHO better to set the codebase to a value which
is correct in most cases than leave it to be "" if not specified in the
html-file.

Pavel Roskin
-------------- next part --------------
Index: libraries/javalib/kaffe/applet/AppletViewer.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/kaffe/applet/AppletViewer.java,v
retrieving revision 1.9
diff -u -r1.9 AppletViewer.java
--- AppletViewer.java	1999/03/11 21:10:09	1.9
+++ AppletViewer.java	1999/06/15 22:59:18
@@ -50,7 +50,7 @@
 {
 	Applet app;
 	Vector apps = new Vector();
-	String codebase = "";
+	String codebase;
 	String archive = "";
 	String code;
 	Hashtable paramDict = new Hashtable();
@@ -65,6 +65,14 @@
 	state.setFont(new Font("SansSerif", Font.BOLD, 12));
 	add( state);
 	addWindowListener(this);
+
+	try {
+		URL codebaseUrl = new URL( "file", "",
+			System.getProperty( "user.dir") + '/');
+		codebase = codebaseUrl.toString();
+	} catch (MalformedURLException _) {
+		codebase = "";
+	}
 
 	try {
 		int ttype;


More information about the kaffe mailing list