• 0

Not easy .jar file - edit


Question

Hello, hope u can help..

I need to edit only one class file, BUT problem.. this class file import 20 others class files.

Example:

import A;

import B;

import a;

import b;

import c;

import d;

import e;

e.t.c...

1. problem: I cant unpack this "A" and "a" "B" and "b" he want replace them.

2. problem: I cant Compile back this .java file to .class file after editing, i using JAVAC, and when trying javac xxx.java - 100 erors in console. I think this is because this Imports or i dont know..

Waiting for ideas. Thanks

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Please feel free to correct me, but you can't edit a .class file in the hopes to modify the code. You'd have to edit the .java file in question and recompile it.

/only took an entry leve Java class, so I'm sure there's alot that I don't know about it.

Hello, hope u can help..

I need to edit only one class file, BUT problem.. this class file import 20 others class files.

Example:

import A;

import B;

import a;

import b;

import c;

import d;

import e;

e.t.c...

1. problem: I cant unpack this "A" and "a" "B" and "b" he want replace them.

2. problem: I cant Compile back this java file to class file after editing, i using JAVAC, and when trying this file, 100 erors in console. I think this is because this Imports or i dont know..

Waiting for answers. Thanks

Link to comment
Share on other sites

  • 0
I know, with DJ javaD i open .Class - edit, then save as .Java.

It doesn't work like that :)

.class files are Java Bytecode, not Java source code. You'll need the original source code if you're going to edit the classes contained within, or you can write your own classes that extend the given classes and override their methods.

Link to comment
Share on other sites

  • 0

Okay, how i understand i cant do it.. all what i need only edit 3 words in .class file

This .Jar was made by very smart scripter, to many traps i catched when trying rewrite him..

Can somebody rewrite him? :(

Edited by musique
Link to comment
Share on other sites

  • 0
It doesn't work like that :)

.class files are Java Bytecode, not Java source code. You'll need the original source code if you're going to edit the classes contained within, or you can write your own classes that extend the given classes and override their methods.

There are tools out there that can decompile .class files back to their .java source. The op mentioned DJ, one of the first decompilers available to the masses (I think they went paid a couple years ago, but you can still find the free version floating around the net)

Problem: I cant Compile back this .java file to .class file after editing, i using JAVAC, and when trying javac xxx.java - 100 erors in console. I think this is because this Imports or i dont know..

Try this:

  1. Put the decompiled .java code in the same directory as your .jar.
  2. Try and compile with:
    javac -classpath .;.\yourjarfile.jar yoursourcefile.java


  3. Replace the extracted classfile with your new one (assuming Step 2 above worked, and you know how to unzip .jar files)
  4. Re-pack the extracted files back to a .jar

Link to comment
Share on other sites

  • 0
There are tools out there that can decompile .class files back to their .java source. The op mentioned DJ, one of the first decompilers available to the masses (I think they went paid a couple years ago, but you can still find the free version floating around the net)

Ah, of course. I didn't know DJ was a decompiler, though I guess it makes sense.

The curse of posting at 2:30 AM :p

Link to comment
Share on other sites

  • 0

If all you need is to replace a two-character String with a different two-character String maybe you can just do an in-place edit of the bytecode with a hex editor (assuming the jar's not signed).

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.