2

I want to use Trove-1.0.2 jar for maps in my java project. I use eclipse IDE. I have added Trove jar using "Add external jars" in Build path, but still I get ClassNotFoundException.

But the class gnu.trove.THashMap is present in the library, when I checked.

Error: java.lang.ClassNotFoundException: gnu.trove.THashMap
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        at com.a.VCLReduce0.reduce(VCLReduce0.java:38)
        at com.a.VCLReduce0.reduce(VCLReduce0.java:1)
        at org.apache.hadoop.mapred.ReduceTask.runOldReducer(ReduceTask.java:519)
        at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:420)
        at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:416)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
        at org.apache.hadoop.mapred.Child.main(Child.java:249)
Grzegorz Rożniecki
  • 27,415
  • 11
  • 90
  • 112
  • Is eclipse not showing you any compiler errors? – ddmps Mar 06 '13 at 16:07
  • no.. i have imported the class, gnu.trove.map.hash.THashMap, so I am not getting any compile errors. I ve added the jar using build path. but still am getting class not found error. I downloaded the jar from maven repository. Is that have to do something with the exception? – Mahalakshmi Lakshminarayanan Mar 06 '13 at 16:15

2 Answers2

0

Check your Runtime classpath in Eclipse (although the library should really be there by default). I guess you're running it in Eclipse using the Run menu.

  1. Right-click your main class.
  2. Select "Run As -> Run Configurations ..."
  3. Expand Java Application on the left-side of the dialog. If you see you main class listed, select it, otherwise click the "New Launch Config" option and ensure that it shows your main class name in the "Main Class" field.
  4. Click the ClassPath tab, and see if your Trove.jar file is listed. If not, then add it and run the app.

If it is on the classpath, it could be that Trove-1.0.2 jar itself has dependencies that you have not added to your build path, though I've checked with Maven Central and this doesn't seem to be the case.

elgaz
  • 121
  • 2
  • 9
  • I run this jar in a hadoop cluster, and after doing the above changes, I still get the error. I downlaoded the jar from here: http://mvnrepository.com/artifact/net.sf.trove4j/trove4j/3.0.2. – Mahalakshmi Lakshminarayanan Mar 06 '13 at 18:30
0

To run a job on hadoop you need to have a standalone jar file with dependencies either unpacked in the jar or specified in the manifest.

See this question for some hints about running hadoop jobs from eclipse: Launch a mapreduce job from eclipse

they also mention this article, it seems to have some good info about setting up eclipse: http://www.mapr.com/blog/basic-notes-on-configuring-eclipse-as-a-hadoop-development-environment-for-mapr

Community
  • 1
  • 1
Denis Tulskiy
  • 19,012
  • 6
  • 50
  • 68
  • Hi, i am running a standalone jar file, which i create using eclipse. Then I upload it to the server and run it. I don't run it directly from eclipse. I saw a pom dependency file from where I downloaded from here: http://mvnrepository.com/artifact/net.sf.trove4j/trove4j/3.0.2 I dont have any manifest file in my project. Can you tell me what I should do for this case? – Mahalakshmi Lakshminarayanan Mar 06 '13 at 18:29
  • @MahalakshmiLakshminarayanan: I don't know if eclipse can build jars with dependencies. I suggest you to take a look and maven or ant. – Denis Tulskiy Mar 07 '13 at 03:17