[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

java+jython: ImportError: cannot import name newString



Hi java packagers,

I need some help to understand an issue I have while trying to package a
java app which exec some jython script.

I came up with the attached simple test case which I compile using:
$ javac -cp "/usr/share/java/jython.jar" TestJython.java

Then I execute:
$ JYTHONPATH="/usr/share/jython/Lib" \
  CLASSPATH=".:/usr/share/java/jython.jar:/usr/share/java/jna.jar:\
  /usr/share/java/asm3.jar:/usr/share/java/antlr3-runtime.jar:\
  /usr/share/java/jna-posix.jar" \
  java TestJython

It gives me the following error:
 Exception in thread "main" Traceback (most recent call last):
   File "<string>", line 1, in <module>
 ImportError: cannot import name newString

While:
$ jython -c "from org.python.core.Py import newString as asPyString"

runs fine.

java and javac are those from java-6-openjdk:
$ readlink -f $(which javac)
/usr/lib/jvm/java-6-openjdk/bin/javac
$ readlink -f $(which java)
/usr/lib/jvm/java-6-openjdk/jre/bin/java

Many thanks in advance,

(Please CC me on replies)

_g.
import org.python.util.PythonInterpreter;

public class TestJython {
	private PythonInterpreter py;

	public static void main(String[] args) {
		TestJython tj = new TestJython();
		tj.go();
	}
	public void go() {
		PythonInterpreter.initialize(System.getProperties(),null,null);
		py = new PythonInterpreter();
		py.exec("from org.python.core.Py import newString as asPyString");
	}
}

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: