Running a Java program with Python

I looked here , here , here and here .

While informative, they simply did not have enough for me to discover the root of my problem. My code is not contained in the JAR file, and the client asked us not to send it as such.

I created an application in Eclipse and from there it works great. I set up a script that will modify the method of mainone of the java files for testing purposes. I want to run an application using a call from Python after changing it. However, from the command line, when I try to call the program with javaor java -cp ., I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: DemoAPIFunctionality
Caused by: java.lang.ClassNotFoundException: DemoAPIFunctionality
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: DemoAPIFunctionality.  Program will exit.

JAR, , DLL , . , , , . DemoAPIFunctionality.java:

public class DemoAPIFunctionality
{
  public final static void main(String[] args)
  {
    DemoAPIFunctionality demo = new DemoAPIFunctionality();

, . (, .) , ?

.

+3
3

, python script java .

Eclipse ( ), , , IDE javac, . java .

java, .

, java com.example.Hello

/dev/bin/com/example/Hello.class

cd /dev/bin java com.example.Hello. , (com.example) (com/example). , java Hello.class ./com/example, NoClassDefFoundError.

+3
  • (.. )
  • java -cp . , , .class, , , com (org ..) .
  • - .. com.package.ClassName
  • IDE - BlueJ JCreator. Eclipse NetBeans .
+4

, . - java classname python. . commands.getstatusoutput("java -cp $CLASSPATH clusterize")

+3

Source: https://habr.com/ru/post/1729635/


All Articles