Question

I installed jython 2.7 beta 1 on Windows and copied its JYTHON_HOME/bin/jython shell script into a $PATH-visible location for MSYS, but calling

$ jython

doesn't work, with this error:

java.lang.NoClassDefFoundError: org/python/util/jython
Caused by: java.lang.ClassNotFoundException: org.python.util.jython
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.python.util.jython.  Program will exit.
Exception in thread "main" 

Having a look at this jython shell script (which I renamed jython.sh), I see it expects either Cygwin or Darwin.

At the beginning of the file I added

export JAVA_HOME='/c/Programs/JavaRE/6u31'
export JYTHON_HOME='/c/Programs/jython2_7b1'

And then where it said

case "`uname`" in
  CYGWIN*) cygwin=true;;
  Darwin) darwin=true;;
esac

I replaced with

case "`uname`" in
  CYGWIN*) cygwin=true;;
  MINGW*) cygwin=true;;
  Darwin) darwin=true;;
esac

But it still doesn't work, with:

$ jython.sh test.j.py
/c/Programs/Path/jython.sh: line 265: /cygdrive/c/Programs/JavaRE/6u31/bin/java: No such file or directory

Internally the jython.sh script uses cygpath, but MSYS doesn't have that, so it falls back on Cygwin's, leading to the above error. How to resolve this?

Was it helpful?

Solution

The solution was to get MSYS's own version of cygpath from here: http://sourceforge.net/projects/cbadvanced/files/Msys%20Specific/cygpath-enhanced.7z/download

And put it into MSYS's /bin

Then running a script like this, works:

$ jython.sh test.j.py

More discussion about MSYS's cygpath.exe here, including why it's not needed: http://mingw.5.n7.nabble.com/enhanced-version-of-cygpath-td28556.html

(To be fair, if it were included in MSYS, then projects will start to rely on it, which is not necessarily the best idea ever.)

Thanks to this answer for the pointer: https://stackoverflow.com/a/18488099/1143274

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top