The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Re: got all .java files ready. how to make them into jar?

1) Compile all of the .java files to create .class files.
2) Create a zip folder.
3) Put all of your .class files into the zip folder.
4) Create a folder named (case sensitive): META-INF
5) Create a .mf file named (case sensitive): MANIFEST and put in META-INF folder. Here is a copy of a manifest from one of my programs:

The Class-Path variable indicates any external libraries you are using and provides full paths to those libraries. For this example, it is saying that the SX.jar library is in the same folder as the executing jar. The Main-Class variable indicates the name of the .class file inside the jar that will be the class with your main. Notice how there is no extension on on the Main-Class variable. Lastly, make sure there is at least 1 extra blank line at the bottom.
6) Put the META-INF folder inside your zip folder.
7) Rename the zip folder to be a .jar instead of a .zip.
8) Double-click to run program.

NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.

Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Re: got all .java files ready. how to make them into jar?

Originally Posted by aussiemcgr

1) Compile all of the .java files to create .class files.
2) Create a zip folder.
3) Put all of your .class files into the zip folder.
4) Create a folder named (case sensitive): META-INF
5) Create a .mf file named (case sensitive): MANIFEST and put in META-INF folder. Here is a copy of a manifest from one of my programs:

The Class-Path variable indicates any external libraries you are using and provides full paths to those libraries. For this example, it is saying that the SX.jar library is in the same folder as the executing jar. The Main-Class variable indicates the name of the .class file inside the jar that will be the class with your main. Notice how there is no extension on on the Main-Class variable. Lastly, make sure there is at least 1 extra blank line at the bottom.
6) Put the META-INF folder inside your zip folder.
7) Rename the zip folder to be a .jar instead of a .zip.
8) Double-click to run program.

Re: got all .java files ready. how to make them into jar?

Do you have an IDE? Such as Eclipse, Netbeans, JCreator, ect. If so, you just have to find the .class files that are made when you compile your program in the IDE.

If you do not have an IDE, you can use the Windows Command Prompt (if you run Windows) to compile the .java files and create .class files.

NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.

Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Re: got all .java files ready. how to make them into jar?

Do you have an IDE? Such as Eclipse, Netbeans, JCreator, ect. If so, you just have to find the .class files that are made when you compile your program in the IDE.

If you do not have an IDE, you can use the Windows Command Prompt (if you run Windows) to compile the .java files and create .class files.

umm okay i have eclipse where u can compile the files but there is a problem :/
it gives alot of errors coz there is different .jar file where is the rest of the methods... so i need to know how to add it there but not inside the project witch i made? so it would use other .jar methods?

Re: got all .java files ready. how to make them into jar?

In Eclipse, right click the project and go to Export. Go to Java->Runnable Jar (if you want a runnable jar). In the following window, choose your class containing the main method you wish to launch with, select how to repackage any external jar files, and define where to save the jar. Click Finish.

Re: got all .java files ready. how to make them into jar?

Originally Posted by copeg

In Eclipse, right click the project and go to Export. Go to Java->Runnable Jar (if you want a runnable jar). In the following window, choose your class containing the main method you wish to launch with, select how to repackage any external jar files, and define where to save the jar. Click Finish.

Re: got all .java files ready. how to make them into jar?

Do you have a main method defined, or is this just a class library? If it's the latter, you can create a simple main method in one of your classes and declare it to do nothing. You can also try using the export as a Jar (not a Runnable Jar).

Re: got all .java files ready. how to make them into jar?

Originally Posted by helloworld922

Do you have a main method defined, or is this just a class library? If it's the latter, you can create a simple main method in one of your classes and declare it to do nothing. You can also try using the export as a Jar (not a Runnable Jar).

Re: got all .java files ready. how to make them into jar?

okey i found the problem...
the problem is that the eclipse gives compile errors when i try make it into .class file and thats why it wont make that full java code inside to the .class... but the client works with that code witch is in the eclipse but i cant get it into .class file :/ so any ideas how to convert it into .class file with errors etc?