From: Jeff A. <ja...@fa...> - 2019-05-13 20:18:24
|
The class path ought to be ignored (by Java) if you supply -jar. (https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html#BABDJJFI) It is possible that changes to the way we look for imports has changed to be more like Java e.g. to use the System properties rather than the environment variable. Or maybe Java changed. (Was it always like this?) Stefan's solution of putting the Jython JAR on the path and invoking the main program looks good to me. The jython.exe launcher takes a --print option that shows you fairly accurately what it would have launched had you not given that option, and this is a good way to get a prototype Java command line. It is not quite accurate for PowerShell: it seems more elements have to be protected by quoting (e.g. "-Dprop=val"). Jeff Allen On 13/05/2019 19:54, Stefan Richthofer wrote: > I once encountered the same problem but never found the time to > investigate it further. > However I can tell you how I solved it (c.f. > https://github.com/Stewori/JyNI#running-jyni): > It seems that one has to avoid the -jar option (not only on Windows). > Instead, put jython.jar on the classpath and execute the class > org.python.util.jython: > > java -cp whatever...;jython.jar org.python.util.jython someFile.py > > Hope this helps! > > Best > > -Stefan > > Am Mo., 13. Mai 2019 um 20:45 Uhr schrieb Niemann, Hartmut > <har...@si... <mailto:har...@si...>>: > > Hello! > > I have a jython program that uses some in-house java libraries. > > It works if I call it with > > jython.exe diagtest.py > > but if I try to start the jar file > > %java32% -cp %CLASSPATH% -jar > c:\SIBAS32\JAVA_LIBS\jython\jython.jar -Dpython.path=%CLASSPATH% > diagtest.py > > (with identical classpath), that classpath seems to be ignored: > > Traceback (most recent call last): > > File "diagtest.py", line 8, in <module> > > from com.siemens.sibas.softsibas import SsbsController > > ImportError: No module named sibas > > JAVA32=C:\DEVTOOLS\Java\1.8-32\bin\java.exe > > JAVA64=C:\DEVTOOLS\Java\1.8\bin\java.exe > > JAVAC=C:\DEVTOOLS\Java\1.8\bin\javac.exe > > JAVADOC=C:\DEVTOOLS\Java\1.8\bin\javadoc.exe > > JAVA_HOME=C:\devtools\Java\1.8-32\jre > > JYTHON=C:\DEVTOOLS\Jython\2.7.0\bin\jython.exe > > CLASSPATH=D:\PRJ\Tools\030_projects\020_Tools\DPS2\050_Tests\..\030_Src\egalsubrdir;D:\PRJ\Tools\030_projects\020_Tools\DPS2\050_Tests\..\030_Src\lib\java\com.siemens.tools;D:\PRJ\Tools\030_projects\0 > > 20_Tools\DPS2\050_Tests\..\030_Src\lib\java\com.siemens.sibas.v4.dm.ctrl;D:\PRJ\Tools\030_projects\020_Tools\DPS2\050_Tests\..\030_Src\lib\java\com.siemens.sibas.v4.dm.tcn;D:\PRJ\Tools\030_projects\02 > > 0_Tools\DPS2\050_Tests\..\030_Src\lib\java\com.siemens.sibas.v4.dm.train;C:\SIBAS32\JAVA_LIBS\SAMAPI4J\SAMAPI4J.030000\*;C:\SIBAS32\JAVA_LIBS\softsibas\*;C:\SIBAS32\JAVA_LIBS\argparse_\*;C:\SIBAS32\JA > > VA_LIBS\com.sun.jna\*;C:\SIBAS32\JAVA_LIBS\jython\*;C:\SIBAS32\JAVA_LIBS\net.ucanaccess\*;C:\SIBAS32\JAVA_LIBS\org.apache.commons.cli\*;C:\SIBAS32\JAVA_LIBS\org.apache.commons.lang3\*;C:\SIBAS32\JAVA_ > > LIBS\org.apache.poi\*;C:\SIBAS32\JAVA_LIBS\org.apache.xmlbeans\*;C:\SIBAS32\JAVA_LIBS\org.ini4j\*;C:\SIBAS32\JAVA_LIBS\services\*;C:\SIBAS32\JAVA_LIBS\sibas\*;C:\SIBAS32\JAVA_LIBS\y\*;C:\SIBAS32\DLLS\ > > SOFTSIBAS\SOFTSIBAS.010000\32 > > The second possibility used to work, so probably I made a mistake > somewhere. Does anybody have an idea what is wrong? > > Mit freundlichen Grüßen > Dr. Hartmut Niemann > > Siemens Mobility GmbH > MO RS LM EN CCI1 SRD > Werner-von-Siemens-Str. 67 > 91052 Erlangen, Deutschland > Tel.: +49 9131 17-50518 > Mobil: +49 173 5342327 > mailto:har...@si... > www.siemens.com/ingenuityforlife > <https://siemens.com/ingenuityforlife> > www.siemens.com/ingenuityforlife > Siemens Mobility GmbH: Vorsitzender des Aufsichtsrats: Anton > Steiger; Geschäftsführer: Karl Blaim, Michael Peter, Sabrina > Soussan; Sitz der Gesellschaft: München, Deutschland; Amtsgericht > München, HRB 237219; WEEE-Reg.-Nr. DE 92917817 > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > <mailto:Jyt...@li...> > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |