I've been trying to edit the .CLASS files inside this program using .jar containers, and a .bat file to launch it.
I'm not familiar with Java, and I've tried Java decompilers but they don't let me edit the source, only copy it. I don't seem to have a program that can actually correctly save and encode it.
What's the best option here to easily edit this Java program's .CLASS files?
Edit: To everyone who's enjoying downrepping this, the program is open source and permits modifications. So thank you for all the blame flinging about it being illegal.
You could try decompiling it with Fernflower, editing the code, then compiling it back into a classfile with the normal javac.
There is no real "easy" way. You could edit the bytecode...but that is a bit more involved. You can use JD but, that as you said, is only so useful.
Use java de-compliler to get source code from byte code, modify as per you want save in different location(like copy source code with your modifications) then compile & run.
Related
I don't want to run my Java program in Eclipse, I want to run it on my desktop like normal program, because I will present it so that it should not looks like amateur.
How can I convert it to desktop application type program?
well, this is somewhat complicated question. when you compile you actually create a jar file, that you can run like a "normal" program. you can take that jar and run, but you need to know that your project my have dependencies on other .jars, pictures, or other type of files. therefor it may be a bit complicated. you can read more about it here or here.
here is a question about making .jar with files(pictures). you might need it
If you want to convert your .jar file to an "executable"/"ready to run file" look at these possible solutions.
It depends on if you are using mac or windows. I have a mac, and I just created an AppleScript to open my .class file that said:
do shell script "cd [filepath]
java [filename]"
and then saved it as an application and changed the icon, I don't know about windows though
This question already has answers here:
How can I open Java .class files in a human-readable way?
(17 answers)
Closed 9 years ago.
How can I open a .class file in Windows 7? I am getting a message saying that I can't see the file and that I have to choose a program to open it or look online for one. Is there any website, explanation, or download that will allow me to access ANY .class file I have extracted or have saved in my Documents?
Are you trying to decompile the .class file and view the source code? You can use Java Decompiler. It has a standalone GUI and also plugin for Eclipse/IntelliJ.
Is there any website, explanation, or download that will allow me to access ANY .class file I have extracted or have saved in my Documents?
It depends what you mean by "access" or "open". It also depends what you mean by extracting ... and what you extracted them from.
If you are trying to run the class files, then the standard way to run a Java application is to use the java command, as documented on the Oracle website. For example: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html. But how you use it depends on the nature of the thing that you downloaded and / or extracted. (Some ".class" files are not applications. Some ".class" files are designed to be run without extracting them from their JAR file container.)
If you are trying to look at the code in the class files, you could use the javap command to disassemble it. Or you could use a third-party tool to decompile it. But unless you have a clue as to what you are doing, this is not likely to help much. And since I can't really guess what you are trying to achieve, I can't offer you any useful references.
If you are trying to do something else, you'll need to explain what it is.
Either way, you need a Java installation on your machine before you can do anything.
You can use the javap command to view the disassembled class file. It is included in the JDK.
I've been provided some external JAR libraries for a project I'm doing. I can access the compiled code but I can't really understand it as its not in the form I'm used to seeing. Any tips on how to 'de-code' and understand what's going on?
Thanks
Search the net for Java Decompilers (e.g. JAD). What you see in a jar is Java-Classes, i.e. the result of compiling .java files.
There are decomiplers you can use them to de-compile .class to .java. We are using JD Java decompiler.
NOTE: I think De-compilation (or) modifying de-compiled code is illegal in some countries. Be aware of it.
You could use a decompiler like JAD to decompile from .class file to .java files, but in my experience its use is quite limited
Try Java Decompiler (Yet another Fast Java decompiler) : http://java.decompiler.free.fr/ .
It can decompile your compiled library.
JAD is only supported up to 1.3.
There should be a documentation and/or source jar that you can attach to your IDE, which will allow you to access the documentation.
If not, you have to decompile it.
Keep in mind that it might be ok to treat this jar as a black box.
I was wondering ... I want to use a plugin-type thing with my Java program.
Here is the situation:
I have compiled a source file (.java) into a .jar file using MY .JAR program as a library. How to I make MY program run the other .jar file internally (using the main program as a reference).
I know this is weird (it sounds weird to me too), but if anyone understands what I am trying to say, please comment.
Thank you all in advance!
OK, here's a draft of how to do it.
Create an interface with a "run()" method.
Your .java plugin must implement that interface.
Load the all classes in classpath (help here Find Java classes implementing an interface)
run your plugin by executing the run method of the interface.
You would have to run the jar using the standard syntax. Your question is basically about running console commands inside java. Here is a nice answer to a similar question:
link!
This isn't necessarily exactly what you want, but it's goal is to put you on the right track, basically you would get the jar placement, then check for the system, then use the technique used there to run a command through the specific platform's console.
Can I change a java file, when I'm running it on JVM, using this file?
For example:
I run abc.java. In this program I've a textarea and I want to paste text from the text area into abc.java and save the changes. Is it possible?
3 steps:
modify your .java file just like you would modify a text file.
compile that .java file from within your already running JVM using javax.tools compilation tools
Instantiate your freshly compiled class using the ClassLoader.
No. Maybe what you want is dynamic define classes at runtime. If so, you could choose dynamic language like Groovy.
The JVM runs class files (.class) and not Java (.java) files. To "convert" a *.java file to a *.class file it needs to be compiled firs.
So change a *.java File will not infuent the JVM in any way, because it is compleatly not interessed in.
Only because of a totality answer
You can write a programm (.java) that when it is compiled an run (.class) change its own source file (.java) (for example changing a string by user input) compiles it (.class), and restart it selfe with its new compiled form. But this is defently not what you want! One would write this kind of software only to prove that this insane idea would work.
Anyway, what you need is a way to store data, in a file or a database. (Have a look at the java.io package for file handling, and for an tutorial).
(new answer for updated question)
"In this program I've a textarea and I want to paste text from the text area into abc.java and save the changes."
This seems like a strange loop, self-modifying java code?
Then yes, the tools nrobey describes would be the way to go, though I agree with Ralph that it might be a bad idea.