I want to create one executable JAR file which contains other JAR libraries. But when I execute the JAR, it gives an error of class path problem.
How do I solve the class-path problem?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you can try it like this;
Here is a simple example for you question. First, we assume we have a project directory like
D:\javademo. In this working directory we then create a main class HelloWorld.java and thtat contains our other JAR files, likecommons-lang.jar. Now, we must archive our main classes HelloWorld and commons-lang.jar into test.jar file.First we must edit our manifest file so that we can specify our class-path and main-class
like this:
We named this file
test.mf. Now we use thejarcommand to generate our JAR file like this:Then it will generate the JAR file
test.jar. You can use this command to run this main class using java command:That is my solution. I hope it give you something helpful…