0

This error keeps bothering me for a long while. I need to export my java app to .jar and when I run it (java -jar test.jar) I get this error message. I've checked that the apache-core-4.3.3.jar is included, I've checked that it contains HttpEntity class, I've checked java build path and manifest but everything is OK.

The weirdest thing is that in my code I don't try to import org.apache.http.HttpEntity at all. And I've got only 3 classes so I wouldn't miss it.

Library imported

Manifest file:

Manifest-Version: 1.0
Main-Class: Main

Classes:

My classes

EDIT I export it like this, so I think imported jars' content is exported to my test.jar file thanks to Export Java source files and resources, am I right?

export

What is the next thing I should do?

4
  • Can you show your manifest file please? Commented Jan 9, 2015 at 8:19
  • @Jens edited, I don't see a problem here. :-/ Commented Jan 9, 2015 at 8:22
  • When you say it is included, do you mean inside the jar? Or inside eclipse like you show in the screenshot? In any case, the fact that you get the exception means that some code or library is using that particular class. Commented Jan 9, 2015 at 8:22
  • @MajorT see my last edit please Commented Jan 9, 2015 at 8:28

3 Answers 3

1

You are exporting it as a 'JAR file', try using the 'runnable JAR file' wizzard.

Right click your eclipse project -> Export.. -> Runnable JAR file -> Pick your configuration and choose "package required libraries into generated JAR". This will make eclipse do al the work for you.

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

Comments

0

You have to add the jars to the classpath in commandline:

java -cp <list of jars> -jar test.jar

5 Comments

like java -cp "org.apache.http-core-4.3.3.jar; nextlibrary.jar; nextone.jar" -jar test.jar?
@2rec Yes but without quotes and pth path name.
excuse me, pth path name is what exactly?
@2rec the path to the jar file in your screenshot C:\eclipse\... or you copy the files in the same directory as test.jar
MajorT's answer is more elegant and also working but thanks a lot for your time
0

Update the class path. It should work

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.