I've looked here, here, here, and here.
While informative they just didn't quite have enough for me to discover the root of my problem. My code isn't contained within a JAR file and the customer has requested we do not ship it as such.
I built the application in Eclipse and from there it runs fine. I've set up a script that will modify the main
method of one of the java files for testing purposes. I want to run the application using a call from Python after I modify it. However, from the command line when I attempt to call the program using java
or 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.
My project depends on several JARs, which are not within the root directory, and a DLL file, again not in the root directory. I'm hoping it's related to the location of one of those but I'm not sure and am making little headway. Here is DemoAPIFunctionality.java
:
public class DemoAPIFunctionality
{
public final static void main(String[] args)
{
DemoAPIFunctionality demo = new DemoAPIFunctionality();
I'd happily list any more information if it will help you help me. (No, I'm not a sports agent.) What do I need to do to get it to work at least from the command line?
Thanks in advance.
java -cp .
from the root directory of your project - i.e. the directory where your .class
file resides, or when you create packages, the directory, where the com
(org
, etc) subdirectory resides.com.package.ClassName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With