restore project from jar file

删除回忆录丶 提交于 2021-01-28 08:02:06

问题


first i'd like to point out that im fairly new to netbeans and java, couldnt exactly find what i need on the web.
I downloaded a software's source files and was modifying it on netbeans. naturally when building the project, netbeans creates in (for example) documents/project_folder/dist/ a lib folder and the finished JAR file that i can use.
if i delete by mistake the source files, and would like to apply all the changes i previously made to fresh source files using the JAR and lib folder i still have, is it possible and how?


回答1:


First of all it is not possible to get a source again from jar file in lib folder. Jar file is executable file which will just contain class files. You can use java decompilers to get source again.




回答2:


NB do not has a version control nor auto save by default. You may have a look on git in NB7.

When you restore from Jar with decompiler there is a big chance to get the source back, even more if you know what your code is all about.




回答3:


You can get the source back by using some decompiler. There are many decompilers available like DJ Decomipler. My favourite is Jd Java Decompiler. Its very small in size and does its job pretty well




回答4:


I'm rather an Eclipse user but I guess both Eclipse and Netbeans are similar to a certain extent. Unless the jar has been created including the source, you won't have other choices that decompile the class files.

When needed, I usually go with JD-GUI which does a pretty good job decompiling jars.




回答5:


It is not possible to retrieve exact source code from a compiled byte code. But there is a possibility to recover your code to some extent

JD is a good Java decompiler. http://java.decompiler.free.fr/?q=jdgui

I think JD is a super hero in cases that the original source code is lost.




回答6:


Keep your source code on any SCM. Use remote SCM not to loose your code. See: google code, github, launchpad etc.



来源:https://stackoverflow.com/questions/10296330/restore-project-from-jar-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!