简体   繁体   中英

How to use Jar file As a Java project in Eclipse

I have a jar file of an existing project. I want to write Junit test cases for each class in that project. To do that, I want to import that jar file as a java project in Eclipse so I can start new development of the same code. Is it possible to import a .jar file the same way we did for a .war file, and start developing the web project? If so, how?

A .jar file is just a .zip file containing all the class files of your java project. If the source files are included in the .jar file, you can unzip it and add them in eclipse. If they aren't, then you can't do what you want to do.

If you have source files in your jar ie .java files along with your .class files, then rename your jar to zip and unzip the files. These java files can now be manually copied under src folder in eclipse.

Once your modifications are done, the new jar with your modifications can be created like this -> Right click on project ->export->Java->Jar option in eclipse. Or you can use ANT/Maven or similar build tool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM