Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to recompile a single .java Java file without having the whole project?

I have this .JAR file. I decompiled it to multiple .java files. There is any way to have a new functional .JAR file, after updating a single .java file and recompiling it? If it is possible how would we recompile this .java file without having it's dependencies? (ie. external libraries)

like image 736
Jader Dias Avatar asked Dec 23 '22 10:12

Jader Dias


1 Answers

Of course!

Ask javac to

javac -cp <whatever classpath you have> path/to/YourClass.java

after that you would say

jar uvf yourjar.jar path/to/YourClass*.class

and you're done, your .jar have been updated, now deploy it!

Remember, .jar file is just a zip archive with classes and manifest!

If your java source references any external classes, you'll need them around. But you also need them around for actually using the compiled class, so I guess it's not a huge problem.

like image 165
alamar Avatar answered May 30 '23 05:05

alamar