Pretty simple, I want to do:
- Use Jython to script/program my Eclipse project
Here are some more parameters:
- I'm on OS X
- Eclipse itself is running in JVM 1.5 (as it must on OS X, sad!)
- My project is compiled in 1.6, and cannot be compile in 1.5 for various reasons.
So, I get pretty far to the console stage, but now I get error such as:
java.lang.UnsupportedClassVersionError: java.lang.UnsupportedClassVersionError: Bad version number in .class file
Oh that's weird, since in "ps xauw" it appears that the jython remote shell is running as Java 1.6 (the system default, and what java -version and javac -version indicate):
41679 ?? S 0:07.29 /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java -Dpython.cachedir=/ [ removed excessively large path here ] /Users/ryan/eclipse/plugins/org.python.pydev_1.4.2/PySrc/pydevconsole.py 49497 49498
Ok, so far so weird. Well let's try this:
>>> import sys
At which point I boggle... Apparently somehow the Jython runs with the Eclipse JVM, which more or less destroys me at this point.
Some docs indicate that there is something about an 'external interpreter' but I see no flag to set such a thing.
So, why does PyDev insist on running jython with the Eclipse JVM, rather than the _system default_ JVM and the _default JVM_ in the Eclipse settings?
So I poked around more, and I did a quick test, kill the jython sub-process, and restarted it by hand from Terminal.app... now the console is semi-broken, but also kinda works... and it thinks sys.platform = java 1.6.
So, something about being spawned from under eclipse is causing Java to be run as 1.5 for some strange strange reason.
Anyone else have any thoughts?
I've done some tests here and it correctly used the default java vm specified at: window > preferences > java > installed jres (it'll use the one checked as default).
Note that the code-completion will spawn a shell with the one configured when first asked (so, if you later change the default, you may need to restart eclipse for Pydev to get that configuration correctly).
Isn't that the one it's using for you?
So I messed around more, and it appears that pydev is using the global default JVM as the one to spawn as.
But what I was seeing is, the JVM would start with the proper _path_ to:
BUT it would internally start up Java 1.5 instead for some reason! When I run the ps xa command by hand, it would run Java 1.6. It appears being a direct child of Eclipse causes subsequent JVMs to be confused.
In the end, I solved my problem by using soylatte instead of the stock/default JVMs.
So, good thing you were able to make it work...
Actually, as you said yourself, Pydev should be using that version. For me, the bug appears to be something more related to the way OS X deals with java (and that might be the reason why setting another VM solved it for you).
exactly - it appears to be (after hours of looking at it) a bug in the way OSX's JVM does it's business. Part of it is the way it switches versions, not relying exactly on symlinks or whatever.
Perhaps someone will see this thread in the future and be spared the hours of work - use soylatte as your JVM! (but not to run eclipse)