I know almost nothing about Java so please take it easy on me. I'm using this plugin, which I've had working nicely for a few days on my Mac (following the repo's very simple instructions below), but when I took it to an Ubuntu instance I got the following error:
ResumeParser/ResumeTransducer$ java -cp 'bin/*:../GATEFiles/lib/*:../GATEFILES/bin/gate.jar:lib/*' code4goal.antony.resumeparser.ResumeParserProgram somefile.pdf somefile.json
Exception in thread "main" java.lang.NoClassDefFoundError: gate/SimpleAnnotation
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: gate.SimpleAnnotation
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)
... 6 more
Anyone have thoughts on what is going wrong?
Installation and usage instructions:
1. git clone https://github.com/antonydeepak/ResumeParser.git
2. cd ResumeParser/ResumeTransducer
3. export GATE_HOME="..\GATEFiles"
Paths are case sensitive in Ubuntu, GATEFiles is different from GATEFILES. Since gate.SimpleAnnotation is in gate.jar, I bet that your classpath should be:
-cp 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*'
Disclaimer: I haven't used this plugin, I don't know if the other parts of the classpath are correct.
In general, you can "debug" by trying
ls ../GATEFiles/bin/
to see if there is a gate.jar file.
It's hard to know, but most likely the class it cannot find is in the gate.jar file, and it is either not on the new machine, or is not in the correct place on the new machine.
To expand slightly: Classes are found in a couple of places, but you specify a gate.jar on the classpath of the command line (that's what the -cp designates), so I'm guessing it's there. Since java can't find it, I'm guessing further that the necessary jar file is not where it needs to be for the Java runtime to find it.
For Linux and OSX use '/' and ':' , try this call .. it worked for me
java -cp './bin/*:../GATEFiles/lib/*:../GATEFiles/bin/gate.jar:./lib/*' code4goal.antony.resumeparser.ResumeParserProgram cv.pdf cv.json
Related
I am attempting to make a simple wrapper around an API connection in Java. I am using the org.apache.http library to do this.
I have downloaded the following jar files:
org.apache.http httpclient saved as ./org.apache.httpclient.jar
org.apache.http httpcore saved as ./org.apache.httpcore.jar
I can then successfully compile the file with:
$ javac -cp "./org.apache.httpclient.jar:./org.apache.httpcore.jar" Api.java
However when running it with $ java Api I receive:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpEntity
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpEntity
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)
... 6 more
[It turned out the issue was with how code was being run after compilation; the code has been removed to avoid distracting from the actual problem and solution]
I can't see why the system has a problem finding the HttpEntity interface when it finds other imports successfully, and can compile. If I remove any of the import lines compilation fails with unknown symbol errors.
-cp should contain the directory where you classes are, for example:
java -cp "./org.apache.httpclient.jar:./org.apache.httpcore.jar:." Api
Assuming that your Api.class is in the current directory. (replace : by ; as classpath separator if your are on a windows system)
Have you tried running the java with '-classpath'. While compiling you are giving the classpath, so you need to add the classpath option for running the class file as well.
More details can be found at below link:
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
Also you can print which libs are in classpath using below command.
java -cp $(for i in lib/*.jar ; do echo -n $i: ; done). com.test.Class
I'm writing a java app and running it on a linux ec2 server.
the program was running fluently yesterday, and after I changed and organazied some files and packages I'm getting this problem when I execute the program:
I'm running the programm with this command:
java -cp . main.Server
And get the following error:
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/json/JSONObject
at main.Group.<init>(Group.java:28)
at main.Server.run(Server.java:23)
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
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
I was running the programm as this before the changes:
export CLASSPATH=$CLASSPATH:/home/ec2-user/java-json.jar
In the bin folder, command:
java Server
And the programm was running.
Since I changed the package from default name to main, I need to run it with the command java -cp . main.Server, but I get the error written above.
I also tried modifing the .bash_profile and add this:
CLASSPATH=$CLASSPATH:/home/ec2-user/java-json.jar
export CLASSPATH
But it didn't help.
I have no errors in my code and the jar is not broken since it worked before. What should I do to fix this problem?
Specify the jar file on the classpath like this:
java -cp .:/home/ec2-user/java-json.jar main.Server
If your classpath is indeed correctly set in your .bash_profile, you could also do:
java -cp .:$CLASSPATH main.Server
I followed the installation here:
http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE#IntelliJ_IDEA
and
http://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL
I'm using IntelliJ IDEA Community 13. Everything compiles nicely but when i go to run the code i get the error:
Exception in thread "main" java.lang.ClassNotFoundException: com.helljogl.OneTriangleSwingGLJPanel
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
I have OpenGL and Java experience, but for some reason this is giving me a huge headache.
I've been at it for hours and have seen similar problems, but found no solutions...
Any ideas?
Rather than adding the dependencies to the project through the IDE, use maven (or Gradle). There's no need to manually download the jogl jar files and mess around with your classpath. See How to set up IntelliJIdea for development using JOGL on Linux and Windows?
After so many Installation Attempts I had jogl.jars all over the place. After cleaning up my environment everything is going smoothly!
I am trying to run a java program and I am getting the following run time error.The error is shown below.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/params/SyncBasicHttpParams
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:157)
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:448)
at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:309)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:466)
at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:286)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:851)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at net.floodlightcontroller.core.internal.PacketStreamerClient.registerForPackets(PacketStreamerClient.java:90)
at net.floodlightcontroller.core.internal.PacketStreamerClient.main(PacketStreamerClient.java:51)
Caused by: java.lang.ClassNotFoundException: org.apache.http.params.SyncBasicHttpParams
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:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more
The error is java.lang.NoClassDefFoundError
Now the Obvious reason of NoClassDefFoundError is that a particular class is not available in Classpath, so we need to add that into Classpath or we need to check why it’s not available in Classpath if we are expecting it to be.
Now the files that I have added to the classpath are the following.
export CLASSPATH=$(JARS=(./lib/*.jar); IFS=:; echo "${JARS[*]}")
export CLASSPATH=$CLASSPATH:~/.m2/repository/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar
export CLASSPATH=$CLASSPATH:~/.m2/repository/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar
export CLASSPATH=$CLASSPATH:~/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
export CLASSPAHT=$CLASSPATH:~/ms_thesis/ONOS/httpcore-4.1.jar
#export CLASSPATH=$CLASSPATH:~/ms_thesis/ONOS/lib/httpclient-4.2.jar
export CLASSPATH=$CLASSPATH:~/google-gson-2.2.4/gson-2.2.4.jar
What jar file should I add to find "org/apache/http/params/SyncBasicHttpParams" I am very new to java and don't know how to debug this issue.
According to the official documentation, the class that you seek is only in httpcore since 4.1. You'll want to pull a new JAR.
org/apache/http/params/SyncBasicHttpParams class is under httpcore-4.1-alpha1.jar , which can be downloaded from
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/httpcomponents/httpcore/4.1-alpha1/httpcore-4.1-alpha1.jar
In future if you need to find a jar for a class, then you can use this link, this is generally helpful:
http://www.findjar.com/
In your case it seems to br you missing out some necessory jar files to include in your project
otherwise you any one of your linked is giving an exception mainly because of static method invocation or intialization
Here's the link to get the jar file httpcore-4.1
I'm currently working with the Tidy class from the JTidy library provided by SourceForge (http://jtidy.sourceforge.net/).
I have already added the .jar library to the CLASSPATH, and I can compile the Java program in SciTE without any error. But when I try to run the program, SciTE prints out this output:
>java -cp . SourceViewer3
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/tidy/Tidy
at SourceViewer3.main(SourceViewer3.java:65)
Caused by: java.lang.ClassNotFoundException: org.w3c.tidy.Tidy
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
>Exit code: 1
Note: line 65 is where I call the constructor of the Tidy class,
Tidy tidy = new Tidy();
But when I try to run the program in command prompt, it runs smoothly without any problem. How can I fix the problem in SciTE?
Additional information: I'm using Windows 7 64 bit, SciTE 3.0.3 and Java version "1.7.0_02".
Nevermind, it is solved now.
Turns out that I must run it by using the command "java (java class name)" rather than using the default command "java -cp . (java class name)" used by SciTE, so that it doesn't override the setting of the CLASSPATH environment variable.
Sorry for the bother ^^;;