From: Hubert Y. <hyo...@ho...> - 2001-10-22 17:01:15
|
Hi Robert, Haven't been able to reply for awhile because of other business stuff, in anycase the situation changed a little though the result is largely the same (not working yet) >I'm not sure this helps, but the code you list below works fine for me >(linux+sunJDK1.3). One thing that might be worth checking is whether >the tryJythonSample class actually exists in a file called >"tryJythonSample.py". The matching classname/filename is required here, >and a difference in those names makes a NPE like you are seeing. > >If that's no help, check back again :) > >-robert Well, getting back to you here's the situation. I'm now using Linux Mandrake 8.1 with sun's JDK1.3.1 and running jython 2.0 anyhow, I did the following, jythonc tryJythonSample.py (same result with --all option) (all code at end of email) copied the compiled code from the jpywork directory into the current one (cp jpywork/* .) javac -classpath /<directory tree>/jython-2.0:. tryJythonMain.java java tryJythonMain Exception in thread "main" java.lang.NoClassDefFoundError: org/python/core/PyProxy at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:486) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111) at java.net.URLClassLoader.defineClass(URLClassLoader.java:248) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:297) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286) at java.lang.ClassLoader.loadClass(ClassLoader.java:253) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) at tryJythonMain.main(tryJythonMain.java:10) Any ideas what this is all about? There is obviously something that I'm doing very wrong since something this simple should work no? Thanks in advance, Hubert btw, tried with jythonc --package tryJythonPackage tryJythonSample.py with the corresponding javac code and slight changes to the source code (i.e. import etc.) And I still get the same error message when I run it. As for the reason to go to Linux from win2k, my machine (which was used by someone else before) was not a clean machine. It had (cound them) three jdk's but a bunch of other junk that should not be there so in the interest of killing as many portential problems as possible I switched to Linux (though admitedly, Mandrake may not be the greatest for development). =================================================================== code tryJythonSample.py import java class tryJythonSample(java.lang.Object): def __init__(self): "@sig public tryJythonSample()" print "Constructor for tryJythonSample" def makeObject(self): "@sig public void makeObject()" print "I have just called a python method!!" tryJythonMain.java import org.python.core.*; import tryJythonSample; public class tryJythonMain { public static void main(String[] args) { tryJythonSample jySample = new tryJythonSample(); jySample.makeObject(); } } |
From: yoshizak <yos...@da...> - 2001-10-22 17:02:43
|
Hi Robert, Haven't been able to reply for awhile because of other business stuff, in anycase the situation changed a little though the result is largely the same (not working yet) >I'm not sure this helps, but the code you list below works fine for me >(linux+sunJDK1.3). One thing that might be worth checking is whether >the tryJythonSample class actually exists in a file called >"tryJythonSample.py". The matching classname/filename is required here, >and a difference in those names makes a NPE like you are seeing. > >If that's no help, check back again :) > >-robert Well, getting back to you here's the situation. I'm now using Linux Mandrake 8.1 with sun's JDK1.3.1 and running jython 2.0 anyhow, I did the following, jythonc tryJythonSample.py (same result with --all option) (all code at end of email) copied the compiled code from the jpywork directory into the current one (cp jpywork/* .) javac -classpath /<directory tree>/jython-2.0:. tryJythonMain.java java tryJythonMain Exception in thread "main" java.lang.NoClassDefFoundError: org/python/core/PyProxy at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:486) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111) at java.net.URLClassLoader.defineClass(URLClassLoader.java:248) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:297) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286) at java.lang.ClassLoader.loadClass(ClassLoader.java:253) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) at tryJythonMain.main(tryJythonMain.java:10) Any ideas what this is all about? There is obviously something that I'm doing very wrong since something this simple should work no? Thanks in advance, Hubert btw, tried with jythonc --package tryJythonPackage tryJythonSample.py with the corresponding javac code and slight changes to the source code (i.e. import etc.) And I still get the same error message when I run it. As for the reason to go to Linux from win2k, my machine (which was used by someone else before) was not a clean machine. It had (cound them) three jdk's but a bunch of other junk that should not be there so in the interest of killing as many portential problems as possible I switched to Linux (though admitedly, Mandrake may not be the greatest for development). =================================================================== code tryJythonSample.py import java class tryJythonSample(java.lang.Object): def __init__(self): "@sig public tryJythonSample()" print "Constructor for tryJythonSample" def makeObject(self): "@sig public void makeObject()" print "I have just called a python method!!" tryJythonMain.java import org.python.core.*; import tryJythonSample; public class tryJythonMain { public static void main(String[] args) { tryJythonSample jySample = new tryJythonSample(); jySample.makeObject(); } } |
From: yoshizak <yos...@da...> - 2001-10-22 18:19:43
|
Hi there, I was looking at the error message and the problem with PyProxy lead me to think I should put the jython.jar into the class path (I believe I saw another e-mail in the user archives that said something about this) don't exactly know why I needed to do this, since I had presumed that this was done by default but when I ran my code sample with java -classpath <some directory tree>/jython-2.0/jython.jar:. tryJythonMain it finally seemed to run. (Yeah! Finally! :) Question is, why did I need to do this? I mean, I'm sure not 'everyone' actually specifies the jar file when running their programs. Do I really need to specify the jar file in the classpath (or CLASSPATH)? In any case, I seem to be able to continue on so thanks for all the help! Appreciate it greatly! Hubert :) |
From: Robert W. B. <rb...@di...> - 2001-10-22 18:39:23
|
Hello Hubert, On Mon, 22 Oct 2001, yoshizak wrote: > Hi there, > I was looking at the error message and the problem with PyProxy lead me > to think I should put the jython.jar into the class path (I believe I > saw another e-mail in the user archives that said something about this) Yes, jython.jar is needed. Using jythonc without the --deep or --all options compiles your script to java bytecode, but running that script still requires the Jython classes found in jython.jar. There are times when using jythonc's --deep and --all options are beneficial because they allow you to include required jython files in a single jar. > don't exactly know why I needed to do this, since I had presumed that > this was done by default Java has no default or intuitive knowledge of Jython, so you must be explicit about these things when running commands that start with "java ". > but when I ran my code sample with > java -classpath <some directory tree>/jython-2.0/jython.jar:. tryJythonMain > it finally seemed to run. (Yeah! Finally! :) Excellent. > Question is, why did I need to do this? I mean, I'm sure not 'everyone' > actually specifies the jar file when running their programs. The classes in jython.jar are always needed. Yes, 'everyone' doesn't always specify the jython.jar file on the command line. Some have explicitly added it to their classpath by some other means or they have used jythonc's --deep or --all option. If you use --deep/--all, the files from jython.jar are included in the output jar; but in the end, the files in the jython.jar file are always needed. > Do I really > need to specify the jar file in the classpath (or CLASSPATH)? The required classes in jython.jar must get stuck in the classpath one way or another. Cheers, Robert |