From: Jeff A. <ja...@fa...> - 2018-10-02 07:48:49
|
Java definitely needs a main(). But, I will admit that I didn't know (didn't remember) that Jython puts one in there! Here it is: PS nomain> javap '.\HelloWorld$py.class' Compiled from "C:\Users\Jeff\Documents\Jython\270\nomain\HelloWorld.py" public class HelloWorld$py extends org.python.core.PyFunctionTable implements org.python.core.PyRunnable { static HelloWorld$py self; static final org.python.core.PyCode f$0; public org.python.core.PyObject f$0(org.python.core.PyFrame, org.python.core.ThreadState); public HelloWorld$py(java.lang.String); public org.python.core.PyCode getMain(); public static void main(java.lang.String[]); public static org.python.core.CodeBootstrap getCodeBootstrap(); public org.python.core.PyObject call_function(int, org.python.core.PyFrame, org.python.core.ThreadState); } Thanks for asking the question. Jeff Allen On 02/10/2018 05:16, Ted Larson Freeman wrote: > Hi, Jeff. > > Another list member replied directly yesterday with this answer, which > solved my issue: > > java -cp /opt/jython2.7.0/jython.jar:. HelloWorld\$py > > I needed the full path to the jar as well as the ":." to include the > current working directory. > > And you're right that the classpath must come first. Several examples > I tried all worked, even just a single print statement. So it must not > be a requirement to have a main() in the Python script itself. > > Thanks for your analysis. > > Ted > > PS. I didn't realize until now that the message I referred to above > had not been cc'ed to this list. > |