1

I'm a Java beginner and have a question similar to the ones here: Java, How to add library files in netbeans? and Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

I followed the answers given there, which were very good, but I still cannot solve my problem.

I'm developing a plugin for GATE in Java using NetBeans 7. I have written this first, trial code:

public class LoadGateDoc {

  public static void main(String[] args) throws Exception {

    Gate.init();  // prepare the library
    Factory.newDocument("This is a document");  // create a new doc
  }

}

But when I compile, I get the following error messages:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at gate.Gate.<clinit>(Gate.java:83)
at loadgatedoc.LoadGateDoc.main(LoadGateDoc.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more
Java Result: 1

I have added the "commons-logging" as well as the "org/apache/log4j/Logger" libraries to the properties of my NetBeans project, but this doesn't help, I get the same error messages anyway.

Can you please help me out?

Community
  • 1
  • 1
user3729787
  • 121
  • 2
  • 11
  • This looks very much like you're working through the example code from the [latest training course](http://gate.ac.uk/wiki/TrainingCourseJune2014/) - have you followed the advice on the previous slide and added gate.jar and _all_ the JARs from `lib` to your project's build path? – Ian Roberts Jul 24 '14 at 09:46
  • Yes, I am following that GATE training course, and yes, I have added the gate.jar and all the JARs from lib to my project's build path... – user3729787 Jul 24 '14 at 10:11
  • In that case it should have worked, but I'm an Eclipse user myself and I don't know enough about netbeans to be able to advise on how to check that the compiler classpath is correct. – Ian Roberts Jul 24 '14 at 10:31
  • OK, thanks. Then I'll wait and see if some NetBeans users will come to my aid! – user3729787 Jul 24 '14 at 10:35
  • HEY THERE, CAN SOMEONE PLEASE HELP ME?!?!?!?!?!? – user3729787 Jul 25 '14 at 09:26
  • GATE lib already has commons-logging jar. Just include all jar files in `GATE/bin` and `GATE/lib` – Ramanan Nov 12 '14 at 09:56

0 Answers0