From: <bc...@wo...> - 2001-07-25 10:11:14
|
Moved to jython-users. [Mark] >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 These last three entries isn't necessary. >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?). Not sure. It is certainly different from the setup used on the applet demo pages: http://www.jython.org/applets. There we make a .jar file that contains all the needed files including the core python files. As a result no CLASSPATH setup is required but the html must then include a line like: ARCHIVE="helloworld.jar". >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) >... > >What the hell does this mean???? Not sure. This is the first time I have seen this message. I'm guesing the stacktrace is a bit bogus. Applets are wellknown for reporting errors that does not reflect the real problem ... >I am using Jython 2.1a1 and JDK (from Sun) 1.3.1 ... and I believe 1.3.1 is the real problem. Even if it isn't, I strongly doubt you can make java1 applets with a java2 JVM. You will need to get hold of and install a JDK1.1 and use that when running jythonc. >For interest sake here are the warning from jythonc: These warnings are not important. We could make them to away but the alternatives does not run as fast. >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 Then I suggest you try to reproduce the way I built the applet demoes. See the "Example" section on http://www.jython.org/docs/jythonc.html >source of the html there is exactly what I have. Not quite, the tag used on the applet demo pages look like this: <APPLET CODE="HelloWorld" WIDTH="160" HEIGHT="50" ARCHIVE="appletdemo.jar" NAME="HelloWorld" ALIGN="BOTTOM" alt="This browser doesn't support JDK 1.1 applets."> <PARAM NAME="cabbase0" VALUE="appletdemo.cab"> <H3>Something has gone wrong loading this applet.</H3> </APPLET> You need the ARCHIVE attribute for netscape (atleast for the windows version) and the <PARAM NAME="cabbase0" ..> tag is needed for older IE browsers. Newer version of IE uses the ARCHIVE attribute instead. regards, finn |