|
From: <mt...@ho...> - 2001-07-25 05:48:37
|
Hi,
I am teaching a simple introductory course on programming. I am using
Python and am interested in introducing at the end for interest sake the
ability to create simple little programs running inside a browser.
I am a bit clueless about Java.
I have CLASSPATH set to:
[mt@galois applet]$ plecho $CLASSPATH
/home/mt/external/jython-2.1a1/jython.jar
.
./jpywork
/home/mt/external/jython-2.1a1/Tools/jythonc
/home/mt/external/jython-2.1a1
/home/mt/external/jython-2.1a1/Lib
I have the following HelloWorld.py file:
from java.applet import Applet
class HelloWorld(Applet):
def paint(self, g):
g.drawString("Hello from Jython!", 20, 30)
Running jythonc -J deprecation HelloWorld.py
produces a class file with 9 deprecated API warnings.
I have the following html file:
<html>
<body>
<center>
<applet code="HelloWorld.class"
width = 500
height = 105>
</applet>
</center>
</body>
</html>
The environment that netscape has does contain the same CLASSPATH
variable (this is required right?).
Here is the java console output:
# Applet exception: exception: java.lang.NullPointerException: trying to call makeJavaPackage(Ljava/lang/String;Ljava/lang/Str
java.lang.NullPointerException: trying to call makeJavaPackage(Ljava/lang/String;Ljava/lang/Str
at org.python.core.PySystemState.add_package(PySystemState.java:504)
at org.python.core.Py.initProperties(Py.java:701)
at org.python.core.Py.initProxy(Py.java:719)
* at HelloWorld.__initProxy__(HelloWorld.java:192)
at HelloWorld.<init>(HelloWorld.java:170)
at netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(DerivedAppletFrame.java:456)
at java.awt.EventDispatchThread$EventPump.dispatchEvents(EventDispatchThread.java:81)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:135)
at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(DerivedAppletFrame.java:911)
What the hell does this mean????
I am using Jython 2.1a1 and JDK (from Sun) 1.3.1
For interest sake here are the warning from jythonc:
Compiling .java to .class...
Compiling with args: ['/usr/local/jdk1.3.1/bin/javac', '-deprecation', '-classpa
th', '"/home/mt/external/jython-2.1a1/jython.jar:/home/mt/external/jython-2.1a1/
jython.jar:.:./jpywork:/home/mt/external/jython-2.1a1/Tools/jythonc:/home/mt/ext
ernal/jython-2.1a1:/home/mt/external/jython-2.1a1/Lib:./jpywork::/home/mt/extern
al/jython-2.1a1/Tools/jythonc:/home/mt/external/jython-2.1a1/Demo/applet/.:/home
/mt/external/jython-2.1a1/Lib"', './jpywork/HelloWorld.java']
0 /home/mt/external/jython-2.1a1/org/python/core/PyString.java:649: warning: getBytes(int,int,byte[],int) in java.lang.String has been deprecated
string.getBytes(0, string.length(), buf, 0);
^
/home/mt/external/jython-2.1a1/org/python/core/PyFile.java:65: warning: getBytes(int,int,byte[],int) in java.lang.String has been deprecated
s.getBytes(0, s.length(), buf, 0);
^
/home/mt/external/jython-2.1a1/org/python/core/PyFile.java:74: warning: String(byte[],int,int,int) in java.lang.String has been deprecated
return new String(buf, 0, offset, len);
^
/home/mt/external/jython-2.1a1/org/python/core/PyFile.java:109: warning: String(byte[],int,int,int) in java.lang.String has been deprecated
return new String(buf, 0, 0, read);
^
/home/mt/external/jython-2.1a1/org/python/core/__builtin__.java:212: warning: java.io.StringBufferInputStream in java.io has been deprecated
return Py.compile(new java.io.StringBufferInputStream(data+"\n\n"),
^
/home/mt/external/jython-2.1a1/org/python/core/PyArray.java:139: warning: String(byte[],int) in java.lang.String has been deprecated
return new String((byte[])data, 0);
^
/home/mt/external/jython-2.1a1/org/python/core/parser.java:70: warning: java.io.StringBufferInputStream in java.io has been deprecated
return parse(new StringBufferInputStream(string), kind, "<string>");
^
/home/mt/external/jython-2.1a1/org/python/core/parser.java:137: warning: java.io.StringBufferInputStream in java.io has been deprecated
node = parse(new StringBufferInputStream(string), kind, filename);
^
/home/mt/external/jython-2.1a1/org/python/core/parser.java:143: warning: java.io.StringBufferInputStream in java.io has been deprecated
node = parse(new StringBufferInputStream(string+"\n"),
^
9 warnings
Anybody have a clue as to what I am doing wrong? I have tried copying
the HelloWorld.class all sorts of different places. I have tried
calling the .class file in the html file different names like HelloWorld
or jpywork/HelloWorld.class jpywork.HelloWorld - pretty much every
conceivable combo.
This applet is working for me at http://www.jython.org/applets the
source of the html there is exactly what I have.
I don't know what I am doing wrong.
Thanks for any help.
Cheers,
Mark
|