How to convert jar file to eclipse project - jar

I want to convert my jar file to eclipse project, so that i can make changes in the existing code. Can anyone help me with this. I tried extracting jar using jar xf myjar.jar command through command prompt but it gave me only .class files and i want to generate .java files of my project through it.

Related

How to update a JAR file with a modfied Java file

I have one JAR named as abc.jar with 15 class files. In JAR file I need to modify xyz.class, so I decompiled to xyz.java and modified it.
How can I update that JAR with the modified Java file? While trying to create (compile) the JAR file I am getting errors.
You can add your newly compiled class to the jar and overwrite the old one, here is how to add xyz.class and xyz.java to the jar :
jar uf abc.jar xyz.class xyz.java
See here for more about updating a jar file.
Or simply you can use any archiving tool, like winrar to open and add files to the jar.
Compile the xyz.java and replace the xyz.class file directly in jar without building the jar again, if the single class has been modified.

Executable jar file is not responding and not running

I wanted to convert .java file to executable jar file,i did so in the command prompt. But everytime i double click (open) it nothing happens.
jar cf Calculate.jar Calculator.java
This is what i typed in the cmd. How to get an executable file? I use windows
That's not how it works, that way you are creating a jar archive with that .java file in it.
If you want to create the jar manually (if you want to do it one time, instead of using a build tool like ant or maven, it could have some educational value), you have to compile your .java file to a .class with javac, add it to the jar and then modify the META-INF/MANIFEST.MF manifest file to specify Calculator as value for the Main-Class attribute.
See this old guide from Sun.

how to compile a java file which is in a jar and then re-create the jar

I have a jar file (Gestp.jar) . And I have some .Java files (which are web applications) within the jar file
I need to modify a particular .Java file . And then re-create the Jar file and deploy it in a server.
I have extracted the jar file , and did the modification to the .Java file. But unable to create the .class file with the changes , in eclipse as it is a web application.
Please help.
Thanks in advance,
Aditya.T

jar file not found iexpress

I am using iexpress to make my .jar files into .exe files
for this I add the jar file(myjarfile.jar) and in run command box I type : java -jar myjarfile.jar
but after creating the .exe the cmd that is flashing says cannot find the jar file myjarfile.jar
can any body help me find what I am doing wrong
To test this, I built a simple HelloWorld.jar file (using these instructions) and tested it like so:
java -jar HelloWorld.jar
Then I made an IExpress package with it. The Install program was exactly the command I used above. This worked exactly as it should.
Two possible causes of the error:
In the IExpress wizard, there's a checkbox Store files using Long File Name inside Package. You should definitely select this option; ignore the warning that appears, as it applies to Windows 95/98. In the .sed file, this is:
UseLongFileName=1
Check that the .exe actually contains myjarfile.jar. 7-Zip will open the .exe and show you the archive contents. (IExpress .exe files are just a CAB file with a wrapper.) If the file is missing, then you'll need to check your .sed file to see what went wrong.

Creating a JAR file which contains other library files

I want to create one executable JAR file which contains other JAR libraries. But when I execute the JAR, it gives an error of class path problem.
How do I solve the class-path problem?
I think you can try it like this;
Here is a simple example for you question. First, we assume we have a project directory like D:\javademo. In this working directory we then create a main class HelloWorld.java and thtat contains our other JAR files, like commons-lang.jar. Now, we must archive our main classes HelloWorld and commons-lang.jar into test.jar file.
First we must edit our manifest file so that we can specify our class-path and main-class
like this:
Manifest-Version: 1.0
Created-By: tony example
Class-Path: test.jar commons-lang.jar
Main-Class: org.tony.java.HelloWorld
We named this file test.mf. Now we use the jar command to generate our JAR file like this:
jar -cvfm test.jar test.mf -C ./ .
Then it will generate the JAR file test.jar. You can use this command to run this main class using java command:
java -jar test.jar
That is my solution. I hope it give you something helpful...
You should use third-party libraries for it. For example, OneJar. You'll have to build the final JAR file using the OneJar tool (like Ant task) instead of standard JRE's tools.
On running such a JAR file, OneJar's service class is launched instead of yours. This class then loads JAR files packed inside, as well as your classes, and run your main class.
There are similar questions and answers already. For example: Stack Overflow question Easiest way to merge a release into one JAR file.

Resources