Edit minecraft pluggin from jar and - java

My friend asked me if I can make some changes to pluggins he send me. I tried googeling them to find the sorcecode somewhere. Sadly it seems that they are not open scource.
So I started decompiling the jar(s) and made the changes in the .class files with IntelliJ.
Now is my question how I can compile it back to a .jar file. Normaly I used maven to build the plugins. But because it isn't a maven project this doesn't work.
I tried creating the jar with:
jar cvf plugin.jar .
but this gives me the error Cannot find main class

Related

Compiling Java Project into Jar file by from command line instead using Maven

I am looking into the github project located at,
SymbolicRegressionInJava. I am familiar compiling java code into jar file but not one huge project using Maven. I looked into Maven and it is another complex system that need to be figured out. The bin folder has already a compiled jar file. I used a command
jar -tf symbolic_regression_1.0.jar
to see the list of classes used for the project. It has both gp and ga directories. I added ga (from another github) folder where is gp folder is at ../src/.. Instead of Maven (which I cannot figure it out even with a tutorials), I attempted manually by typing
jar cvf test1.jar *
It compiled, however, it failed to run like symbolic_regression_1.0.jar. What I am missing here?

Difference between Run in eclipse and going to the project folder and using the .jar

I'm trying to find more information on how eclipse handles Running a project.
I want to understand it more because I have an issue I'm currently having where apache-poi .jar files which have been included into the classpath of my project will work properly when the project is ran through eclipse, but will not be detected when going to the same projects folder and running the main jar file to start the program.
It gives me the error: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Cell (although sometimes instead of Cell, it's Sheet)
What could I consult to understand what is going on here, and possibly solve this issue?
Your NoClassDefFoundError indicates that the library was not available while running the jar.
This depends upon how you are exporting your project into the jar file.
If you're using eclipse to do so, you can:
Export->Java->Runnable Jar to create a jar that includes its dependencies
Make sure to check Package required libraries into generated JAR.
This will make all your jars (in build path including apache-poi.jar) as a part of the final jar.
It runs from eclipse because libraries are on the build path of the eclipse which makes them available in the classpath.

how to pack external jar into output jar file in eclipse

I'm currently working with J2me by Mobile Tools for Java (MTJ) on Eclipse. My program need to encrypt SMS messages by RSA so i try to use bouncycastle library. I download bouncycatle version 1.47 and add to to my buildpath. No problem occurs when building project. But when i try to run on emulator, i get this error:
TRACE: <at java.lang.NoClassDefFoundError: org/bouncycastle/crypto/engines/RSAEngine>, startApp threw an Exception
It's a common problem, NoClassDefFound. To solve this, i know i must include the class file of bouncycastle in classpath. But here come the problem, i cant pack bouncycastle class file into the jar which MTJ created. For regular project, all i need to do is tick on the checkbox in "Order and Export" tab to have all class files in the "ticked" referenced library packed in to output jar. I do the same here but after i create package, i check the new jar file and no class of bouncycastle is inside (check using WinRar).I did some
I'm using Eclipse Indigo Release 2, build-id: 20120216-1857, MTJ version 1.1.2.
I also tried to create package by eclipse Pulsar 1.3.1 but the problem still persists.
Is there any suggestion? is this a bug?
Regards.
"Order and Export" is not working as you think it is. If you have two projects - ProjectA and ProjectB and ProjectA dependends on ProjectA, then if ProjectA needs some.jar and you find out that ProjectB needs some.jar too, then "Order and Export" for that jar in ProjectA makes it "visible" also for ProjectB.
For JAR files you cannot add another jar into the JAR files (it works for WARs and EARs). There are two possibilities how to solve this
you can unzip required JAR and add class files to your jar, jar -u can help you (this seems difficult, but if you are using ant or maven you will configure that once)
you can try to use MANIFEST headers

NetBeans & Executable JARs

New to NetBeans dev here. When I first created my project and began compiling, I noticed that NetBeans had automatically created a dist/ directory under my project root and was creating an Executable JAR in that directory.
I've now been developing for several weeks, and added many resource files to my project, including a system log file, an embedded SQLite database, and several properties files. These are files that my program (a Swing app) needs to read/write from at runtime in order to function correctly.
I just noticed this morning that the Executable JAR in my dist/ directory is several weeks old, and that compiling my project doesn't update it. I am wondering if that's because there are now all these new resource files and NetBeans doesn't know how/where to package them for the automatically-created Executable JAR.
Does this mean that I'll have to tweak the build.xml myself? Or is there a NetBeans dialog I can get to where I can specify where to pacakge everything? And if NetBeans should be doing this automatically, what could be the reason that it stopped creating the JAR for me, and what can I do to force this functionality again?
I went into Project Properties >> Packaging and made sure that the JAR file directory was still dist/MyProgram.jar and that the checkbox Build JAR after compiling was still checked, so obviously something else is either breaking the build or messing with NB.
Thanks for any tips!
If "Compile on Save" is enabled, then your .jar file will only be generated when you do a "Clean & Build" (Just "Build" is not available when "Compile on Save" is enabled)
You need to Clean and Build within netbeans to update the file within your /dist directory.
I use Netbeans 7.0 and this solution works for me.

Add python module to JAR classpath in Eclipse

I have a Java project that utilizes Jython to interface with a Python module. With my configuration, the program runs fine, however, when I export the project to a JAR file, I get the following error:
Jar export finished with problems. See details for additional information.
Fat Jar Export: Could not find class-path entry for 'C:Projects/this_project/src/com/company/python/'
When browsing through the generated JAR file with an archive manager, the python module is in fact inside of the JAR, but when I check the manifest, only "." is in the classpath. I can overlook this issue by manually dropping the module into the JAR file after creation, but since the main point of this project is automation, I'd rather be able to configure Eclipse to generate properly configured JAR automatically. Any ideas?
*NOTE*I obviously cannot run the program successfully when I do this, but removing the Python source folder from the classpath in "Run Configurations..." makes the error go away.
Figured it out, had to add the source folder with the Python module in it as a class folder in the Build Path project properties. Not sure if this next part is necessary or not, but since the module is not compiled, I added the folder again as "Attached Source" after adding the class folder.
Have a look at the maven-jython-compile-plugin and its demo project at http://mavenjython.sourceforge.net/ . It allows bundling jython with dependencies into a standalone jar.

Categories

Resources