Jump to content
  • 0

Edit jar files


barao45

Question

Hi Friends. I am learning a little how to edit jar files from the Core, i Need to modify the engine.jar to add some lines in donatemanager class for the classes changer but i got an error when i import the jar file to my proyecto,for example error in imports Like log4j.

Could you explain the Steps to modify and import this files to our project?.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

If you need change any class from JAR package then you need:

 

  • Decompile the target class;
  • Create new Java project in IDE as container of target class (project can includes only "dead code");
  • Normalize all fields and methods;
  • Restore all imports with external dependencies;
  • Compile as new project;
  • Replace new class from new JAR package to old.

For all you need any IDE (Eclipse, IntelliJ IDEA) and any Jva decompile (e.g. Java Decompiler)

  • Like 2
Link to comment
Share on other sites

  • 0
11 hours ago, Rootware said:

If you need change any class from JAR package then you need:

 

  • Decompile the target class;
  • Create new Java project in IDE as container of target class (project can includes only "dead code");
  • Normalize all fields and methods;
  • Restore all imports with external dependencies;
  • Compile as new project;
  • Replace new class from new JAR package to old.

For all you need any IDE (Eclipse, IntelliJ IDEA) and any Jva decompile (e.g. Java Decompiler)

 

}

Thanks Root, i have exported source from engine.jar, i have created a Java Project with java 11 because Sunrise use that. then i copy the files to the project and imported a library of l24j. That error has been resolved, but tha source has an error because cant find de l2r.DatabaseFactory and L2PCInstance. i share the images.

If i export that source i think that it wouldnt work.

 

https://ibb.co/z28XxKg

https://ibb.co/TvZbYf8

Link to comment
Share on other sites

  • 0

You need restore all dependencies. It means you need:

 

  • reproduce classes irerarchy and package location (e.g. if target class locates by path "l2j.net.sf.gameserver" you need create this package path in your new project and put there target class);
  • if target class calls some methods from classes from this package then you need create this classes as DUMMIES and reproduce them empty methods/fields for exclude logical errors while compilation. This names as "make a dead code";
  • compile result and take modified class for replacing.

That's all steps i meant by phrase "Restore all imports with external dependencies".

 

Sometimes recompilation the target class requeres a lot of time and new project can includes few hundreds "depended" classes. You must be ready for this.

  • Like 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...