0

I have a big application that worked perfect inside eclipse, I create an executable jar file for my application, My application use jython to define some resources. Also I create `the following .bat file to run the file:

    @ echo off 
java -Xms64m -Xmx512m -Xincgc -Dpython.home=jython-2.1 -Dpython.path=jython-2.1/Lib/alice -Djava.library.path=lib/win32;externalLib/win32; -jar MyProg23.jar

When execute the .bat file an exception appeared, this is a part of this exception:

java.lang.ExceptionInInitializerError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at edu.cmu.cs.stage3.alice.authoringtool.JAlice.main(JAlice.java:163)
Caused by: Traceback (innermost last):
  File "C:\MyWork\AliceDev\Alice test\resources\Alice Style.py", line 23, in ?
  File "C:\MyWork\AliceDev\Alice test\resources\common\StandardResources.py", li
ne 181, in ?
AttributeError: java package 'javax' has no attribute 'vecmath'

        at org.python.core.Py.AttributeError(Py.java)
        at org.python.core.PyObject.__getattr__(PyObject.java)
        at org.python.pycode._pyx1.f$0(C:\MyWork\AliceDev\Alice test\resources\c
ommon\StandardResources.py:181)
        at org.python.pycode._pyx1.call_function(C:\MyWork\AliceDev\Alice test\r
esources\common\StandardResources.py)
        at org.python.core.PyTableCode.call(PyTableCode.java)
        at org.python.core.PyCode.call(PyCode.java)
        at org.python.core.Py.runCode(Py.java)
        at org.python.core.__builtin__.execfile_flags(__builtin__.java)
        at org.python.core.__builtin__.execfile(__builtin__.java)
        at org.python.core.__builtin__.execfile(__builtin__.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
)
        at org.python.core.PyObject.__call__(PyObject.java)
        at org.python.pycode._pyx0.f$0(C:\MyWork\AliceDev\Alice test\resources\A
lice Style.py:23)
        at org.python.pycode._pyx0.call_function(C:\MyWork\AliceDev\Alice test\r
esources\Alice Style.py)
        at org.python.core.PyTableCode.call(PyTableCode.java)
        at org.python.core.PyCode.call(PyCode.java)
        at org.python.core.Py.runCode(Py.java)
        at org.python.core.__builtin__.execfile_flags(__builtin__.java)
        at org.python.core.__builtin__.execfile(__builtin__.java)
        at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.loadReso
urcesPy(AuthoringToolResources.java:199)
        at edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources.<clinit>
(AuthoringToolResources.java:108)
        ... 3 more

The vecmath.jar file and other external lib are founded inside a folder called externalLib which in the same folder of the Myprog23.jar and .bat files

How to solve the problem and what is need to be set?

lucidgold
  • 4,176
  • 4
  • 26
  • 46
Jar
  • 11
  • 2
  • The structure of your error says you are having problems with vecmath getting imported via jython. Try to install jython "globaly" by following these [instructions](http://www.jython.org/archive/22/installation.html). – lucidgold Apr 09 '15 at 05:32
  • jython already installed, I put all the exception which may make it more clear. - @lucidgold – Jar Apr 10 '15 at 07:12

2 Answers2

0

You need to add all jars used in program to classpath. So, in your case all jars present in externalLib directory should be added in classpath.

For adding jars in classpath you may refer Setting multiple jars in java classpath

Community
  • 1
  • 1
Bhisham Balani
  • 228
  • 1
  • 4
  • I add the _classpath_ for jar files which cause the problem, but the problem is still appeared. Is there any other idea to setup the environment to use javax.vecmath with jar files. The project work inside eclipse perfectly, so I think the problem is only how to set the VM environment on my machine to let the application works with these external libraries. @Bhisham – Jar Apr 08 '15 at 16:54
0

I am assuming that you have correctly set your CLASSPATH variable. Also assuming you have correctly installed JyThon. You should really make sure to TEST JyThon hello world OUTSIDE of your application environment as well. You need to take this step by step, Alice is a complex system, and so it is difficult to debug your issue without making sure basic structure of libraries is in place.

With these assumptions, you can proceed with JyThon documentation FAQ:

Jython cannot find your Java class, even though it exists in the class path.

Jython cannot find your Java class, even though it exists in the class path. This shows up as "ImportError: cannot import name xxx" or "AttributeError: java package xxx' has no attribute 'yyy'" This happens when Jython is installed as a Java extension (i.e. when jython.jar is installed in java\jre\lib\ext) and your classes are installed in the classpath.

The reason is Java extensions can only see other extensions, not other classes defined in the CLASSPATH or passed in to java using the --classpath option.

There are two ways to fix this:

  1. Move your classes to the java\jre\lib\ext directory.

  2. Remove jython.jar from the java\jre\lib\ext directory and put jython.jar in the CLASSPATH or use the java --classpath option.

lucidgold
  • 4,176
  • 4
  • 26
  • 46