When launching a Java application, Java is looking for a main class.
There are two ways to provide this main class:
Either specify it directly on the command-line:
Either specify a jar (whose manifest points to the main class):
java –jar myJarFile.jar
https://docs.oracle.com/javase/tutorial/deployment/jar/run.html for some background)
In your second example, you are just providing jython as a library on the classpath.
This instructs Java to browse through that library for any required classes.
You don’t specify though which class it should be executing.
Van: John Dunn [mailto:[hidden email]]
Verzonden: woensdag 26 november 2014 17:26
Aan: [hidden email]
Onderwerp: [Jython-users] Complete newbie question
Having come from a pure python background, trying to understand jython and java
Why does this work :
$JAVA_HOME/bin/java -jar jython-2.5.3.jar hello.py
But not this :
$JAVA_HOME/bin/java -cp $CLASSPATH hello.py
Error: Could not find or load main class hello.py
The jar file is in the current directory.
if __name__ == '__main__':
Any help appreciated. Please be gentle!