I need to debug or better to patch a .jar file which is loading from other Jars / .exe File.
I can decompile the .jar pretty well but it seems to be that Eclipse or IntelliJ need a main function to debug it.
Is there a Way to decompile it change the specific class, recompile all and replace the .class /.java file into the packed jar? A complete compile of all decompiled files from the .jar will not possible i think. There are some "unable to decompile" Marks in other, for me not relevant .class files
Related
I was curious about the differences between .jar with .class files and .jar with .java files. I partially got the answer here, But then what is the usefulness of .java files in the jar?
My guess is that the java files in the jar are like an interface that prevents compilation error, because I solved the IllegalAccessError thrown on runtime by replacing jar files with .class with jar files with .java specifically when using Xposed Framework. (Got the hint from this thread.)
Also
Thank you for your explanations and they were helpful. But I want to learn more about the differences in compiler's view, because I am wondering why my app works fine even if I only included the jar with java files, not class files (zxing). Also there are some cases that throws IllegalAccessException when I include the jar with class files, but not thrown when I include the jar with java files(xposed), even though I have to include at least one of them to make the compiler(AIDE) not complain about references, like unknown package. Why does the compiler not complain when I include only jar with java files though the compiler would not be able to resolve the actual implementation of the referred classes?
A .jar file is basically just a .zip file with another extension.
A .jar file with .class files have a special purpose and may have special meta-data (e.g. in META-INF folder).
A .jar file .java files is just a .zip file.
It is however common for open-source libraries to provide 3 .jar files:
One with .class files, to be used by your code, both to compile and to run your code.
One with .java files, to be used by your IDE, so you can drill into the library code and see it. Especially useful when stepping through the code with a debugger.
One with javadoc files (.html files), to be used by your IDE, so you can read the documentation about the classes and methods in the library. You do read the documentation, right?
None of those 3 files have to be named .jar. They could be renamed .zip so you could easily open them in your favorite Zip utility, or they could be renamed .foo just because...
They should be named .jar, to clarify that they are Java ARchives.
Its simple - *.java files are sources, *.class files are compiled classes.
What is used on runtime by JVM?? *.class files. Why would you put source files inside library? IDK, usally sources are distributed as separate jar, but all in all it is done to allow you to check library code without decompilation.
I did some robot framework python examples with pybot, and referenced .py files as my library files. The folder structure I used was test/lib/myLib.py and test/test/myTest.robot, where /test was at the same level as the /src folder in my project in eclipse.
I then tried to do similar things with a java project using jython. I have /test/test/myTest.robot which imports the library ../lib/myLib.java. I even tried importing this file using RIDE, but it always shows up as red text, meaning the import failed. The specific message I get from using jybot on the command line is:
"Importing test library 'C:\Users\cody\git\myProject\test\lib\myLib.java' failed: ImportError: No module named myLib"
I read that I might need to add it to classpath, and I think in order to do so, I need to make it a .jar file. I'd rather not do all that if possible to just leave it as a .java file. I attempted to add the lib folder to the build path... By that I mean I added the /test/lib folder to the "Source folders on build path". I also exported the darn thing as a jar and added that as a library. All this was done from the project properties in Eclipse.
I'm pretty stuck... any ideas how to get this working?
Java being a compiled language, you need to compile your java Class before importing it with RobotFramework.
Normally, Eclipse would do that for you, and put the resulting .class files inside a bin repository. If not, you can issue the javac path/to/file.java command, and move the resulting .class file where you want it (somewhere referenced by the classpath.
From within the .robot file, you should have the line Library test/lib/myLib, without neither .java nor .class at the end.
How can I edit code in a .class file in a .jar file using Android Studio? I have already tried to edit it of course. The class I am trying to edit is a read only for some reason.
Jar files are compressed archives (zipped files) of .class files( and few other resources). .class files are compiled .java files. You can not edit a compiled file in normal situation unless you decompile to get source code, edit the code and recompile again.
Decompiling is a tedious process, thus getting a source code is the best option here.
Note: You can rename the .jar file to a .zip file and can open it using any compression tool such as winrar or winzip to see the content.
I work daily on a large customized version of Android. Our work involves creating new APIs and testing them with our in-house test app. Currently, each person checks out the needed files to make API updates and then requests that I create a new version of the test app that works with their changes. The way I accomplish this, in part, is with a script that grabs their version of the OS files (the ones that declare the APIs) and generates a JAR of these files that is then thrown in the test app's "lib" directory so the test code can reference these new/changed APIs.
I've been able to automate so much of my workflow, but I can't find a way to automate the task of generating the jar from a few .java files that can't be compiled in isolation. I know how to create a jar and manually populate it, but I can't figure out how Eclipse is able to generate .class files for .java input source files that can't be compiled by themselves. The only way that I can currently compile these files is with a multi-hour full OS build, which I don't want to wait on. Also, our build servers don't spit out the individual .class files I would want to zip up in a JAR anyways.
So, does anyone know how to generate a JAR file with .class files compiled from .java src files that appear, by themselves, to be riddled with errors? I currently do this manually with Eclipse's "export project to JAR" ability, but it really irks me that it's the only "non-automate-able" step in my process so far.
I found this, which doesn't handle generation of the .class file(s) from a set of .java files that won't compile alone.
Thanks!
I am using eclipse IDE and want to edit the attached source file of the jar file. For doing this i downloaded the src.zip and attached the file, but it is opening as a .class though I am able to read the file (which is a .class file) but i also want to edit the file.
Why I am not allowed to edit it? how to open an attached file with .java extension not .class extension.
thanks in advance
That's not possible. In order to edit the source, you have to unpack the JAR and create an eclipse project, from which you can then create a JAR with the modified code.
Because you have to link it... Source files are not tied to compiled classes in jar, so if you edit it, nothing will happen to the jar file
You have to create a separate project in Eclipse, and rebuild the jar with your modifications
.class files are not readable by human being unless you decompile it. Many decompilers exist. Carefull about what you are allowed to do and what you aren't, though...
Usually, .java aren't in .jar.