Reputation:
I wrote a code using Java Editor and now I am trying to create a jar File from it. Creating one from my early codes (just Hello World and stuff) worked well. But with this code it seems not to work. Java Editor says that it compressed until 48% and then it stops. Opening the jar does not work. I looked up a lot of "tutorials" on creating a jar file but all of them just showed how to press the button on the top, which I did. I also tried Jarfix (didn't work). Can anyone here help me?
Upvotes: 0
Views: 94
Reputation: 2652
proj
(or any other name) to
isolate your work from existing files.Step 2: Within that directory of step 1, create another directory
named com
and within com
create one more directory named quest
.
Step 3: Now put the following Hello.java in the directory named quest.
package com.quest;
public class Hello{
public static void main(String[] args){
if(args.length==0){
System.out.println("Hello World");
}else{
System.out.println("Hello "+args[0]);
}
}
}
Step 4: Create a text file named MANIFEST.MF
in proj
directory with following content.
Please remember to press enter after typing the last line (here only one line) of the file.
Main-Class: com.quest.Hello
proj
. Compile the
Hello.java
with following command. Assuming that javac
is in
your PATH.C:\Users\Admin\Desktop\proj>javac com\quest\Hello.java
Step 6: Create executable hello.jar file with following command:
C:\Users\Admin\Desktop\proj>jar cmf MANIFEST.MF hello.jar com
Step 7: Run it:
C:\Users\Admin\Desktop\proj>java -jar hello.jar Infonyx
Details are available here: https://docs.oracle.com/javase/tutorial/deployment/jar/build.html
Please let me know it works or not.
Upvotes: 1