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 |
From: Mats W. <ma...@la...> - 2001-07-27 11:32:43
|
At 10:12 AM 7/25/2001 +0000, Finn Bock wrote: >>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. I'm wondering if there are any sensible solutions to this. Can the 1.1 JDK coexist with a 1.3? I had understood that the purpose of the "Java plugin" that now comes bundled with the 1.3.x distribution kit was for this reason: you can't count on the browser, but you can add a plugin to take care of it. I haven't had any joy making that work, however. Is there something special one can do - thus enabling a 1.3-built Applet to run? i've sometimes detected that the plugin is active, but I seem never to have gotten it to work for a Jython-built applet. I don't believe this compatibility headache is unique to Jython, but the situation's not going to get better: Sun's started the end-of-life track on the 1.1 JDK (thus "continue to build with 1.1" is not going to remain a viable story). It also doesn't help that Microsoft is dropping Java support entirely in Win XP and IE. So back to the Java plugin question: how do I make that work, in the likely event I'm missing something. Mats |
From: <bc...@wo...> - 2001-07-27 12:08:35
|
[Mats] > >>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. > >I'm wondering if there are any sensible solutions to this. >Can the 1.1 JDK coexist with a 1.3? It can. I have JDK1.1.7A, JDK1.2.1, JDK1.3, JDK1.4, IBMJava1.3 and MS-SDK4.0 all installed in the same directory. Some hints (for windows) off the top of my head include: - I don't set PATH or CLASSPATH in the controlpanel. Instead I have some small .bat scripts that let me choose java versions. - When installing a Java2 from javasoft, I *always* remove the java.exe file in the windows system directory (c:\WINNT\system32 IIRC). >I had understood that the purpose of the "Java plugin" that >now comes bundled with the 1.3.x distribution kit was for >this reason: you can't count on the browser, but you can >add a plugin to take care of it. I haven't had any joy >making that work, however. Is there something special one >can do - thus enabling a 1.3-built Applet to run? i've >sometimes detected that the plugin is active, but I seem >never to have gotten it to work for a Jython-built applet. Sorry, I have no experience with the plugin. Anyone else? I think it is possible to make a sandboxed plugin applets, but not all the infrastructure is in place for applets that want to move outside the default security. >I don't believe this compatibility headache is unique to >Jython, but the situation's not going to get better: Sun's >started the end-of-life track on the 1.1 JDK (thus "continue >to build with 1.1" is not going to remain a viable story). When java1 applets are the goal, I doubt there is any alternatives. We may be able toi improve the situation slightly, so that it isn't necessary to have jython installed with the jdk1.1. But the jdk1.1 class files (classes.zip) must still be available when building applets. regards, finn |