0

I have a JAVA (awt) Project to build a desktop base utility. When I try to run this from other machine with only JRE Installed this is giving an exception as

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at DataProcessor.DataProcessor.App.<clinit>(App.java:73)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Unknown Source)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.base/java.net.URLClassLoader.findClass(Unknown Source)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)  

here I am not using a maven project, creating an executable JAR directly from eclipse. All though I see the JAR for log4J (log4j-1.2.17.jar) in the MANIFEST. But this is giving an exception when I try to run it from other machines. ( Other machines has only JRE not JDK) following command I am using to run JAR

C:\Users\<username>\Desktop\Utility\latest>"C:\Program Files\Java\jre1.8.0_161\bin\java.exe" -jar Utility.jar
1

1 Answer 1

0

The exception is sayin' that you don't have the log4j dependency found on your class path: are you providing the log4j.jar in the same folder as the one in which your jar is placed?

It is not so easy to reference other jars when running an application as java -jar yourApp.jar ...

  • You can take a look to this post about this referencing a jar when running another one;
  • If you want to investigate about MANIFEST usage, take a look here;

However, i suggest you to use maven (or do it manually) exporting a fatjar with the needed dependencies packaged into (take a look to maven-assembler plugin or Eclipse runnable jar export options).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.