I have a java package with many java class and many main. i wish to make jar from these package ? can you help me please ?
(i work with netbeans )
If the project is under netbeans IDE, you should follow these steps:
Right click on the project and then click on Properties
Click on Packaging
Click on Compress JAR File
Accept changes, click OK
Right click on the project and then click on Clean and Build
Go to the directory where your project is stored
Look in the dist folder for the JAR file
To select the main class that will be executed
Click on Run
Click on Browse near to Main Class label
EDIT :
If you are using netbeans under windows, and if the jar file does not generate any output, try the following command in cmd :
start /b <jar file>
Then an error should appear
So you can know what is the problem
Right click on the the project in net beans project window and choose Project Properties -> run , there you can setup your main class
clean and build your project and go to your netbeans project -> your project -> dist there is the executable jar file.
selected main class will be executed when you execute the generated jar file
I found this site useful... Hope it helps
deploying jar
Related
I have done a small RPG in Eclipse IDE. Now I want to share it with some friends who are not using IDE.
I read that I need to export my project into .jar or executable jar. Well these to process are not able to finish without errors.
This is my project: The hierarchy of my project.
I will show you the step I am following to export:
Right-click on the project > Export > JAR file (Export)
Add my project to the .jar (Export options)
Add my package and the main class (Export options 2)
Then I click on finish and then the errors appears (The errors)
After that the .jar come in the folder but doesn't work at all.
Please help me.
Try to use this tool:
https://ninjacave.com/jarsplice
Here´s a tutorial, how to export the Slick2D-App (But It´s in german):
https://www.youtube.com/watch?v=N8wwewUqg9E
I have multiple classes like Index.java, Login.java, Create.java, Update.java in my package. I have tried to make jar file with netbeans this way
Run -> Clean and Build Project
It generates a jar but when I run it, then it starts with Index.java but I want the project start with Login.java
Right click on project ,
properties->Run->Main class
change it's value to your Login.java , then clean and build again.
this screenshot is from netbeans 8.0.2
try Oracle Docs Step 1 or Oracle Docs Step 2
I set a lookAndFeel synthetica theme for the project.After that it is not working(jar file in the dist).
Again I removed it and tried.Then it worked. I did clean and build.
Tried several themes. They all workedd in the project. But did not run in the dist.
What should I do? Please help me..
I have experienced this before in my projects. Most of the time it happen because of using icons and images.
When /Icons/calculator.png image in your package, it is not wrong in netbeans like this getClass().getResource("/Icons/Calculator.png").
this is working on netbeans. but not in jar file. you need to rename Calculator.png.
use jar file in console (CMD in windows , shell in linux) with this command
java -jar adress-jar-file/jarfileName.jar
then see error in console.
Just Right click on yoru projet in netbeans and select Set Configuration then Customize in the window that appears provide your Main Class by clicking the browse button or writing it manually and Clean and Built again
Plz make sure some points.
1) You have set main class properly.
Right click on Project-> project properties-> Run-> set Main-Class
2) You have set theme path properly.
3) Your themes are not corrupted.
4) You have build your jar properly.
Right click on project-> clean and build(Note: Do nothing while it finish building jar)
5) Your lib folder not corrupted (if it is present).
It looks like there maybe something wrong with your setup. In your project properties, under libraries have you by chance added synthetica.jar as a required jar. but m not sure try it
but you can simply do,
you could create lib folder manually in your project folder and then paste that jar in that folder then through netbeans go to your project then right click on libraries and then browse to find your project folder open that then click on lib folder that you have created open it then click on jar that you have pasted and that jar file will be added to your project.
I could resolve my problem.I'm sorry that I was used trial version Synthetica.jar. after I bought it and done every thing from the beginning. I resolved it. Thank you for your contribution to resolve it.thank you
I want to create a jar file in Netbeans using the clean and build options. The jar file is created, but the manifest file is not updating; this means the main class is not set in the manifest file, so when I run the jar file, it has the "could not load main class" error.
How do I handle this and how do I add main class in project properties?
Right click on netbeans project and select "Properties"
Then select "Run". There is option for selecting main class. Select main class from there.Then click "ok".
After doing this try run your project at least once before building your jar file.
Hope You did not set up main class in project setup.
So do right click on project.
then go to properties.
On that screen you can see Run configuration.
There is place to configure main class of you jar file.
So configure your main class at there and press ok.
Then clean and rebuild the project.
After that manifest file should update.
May be you are running your project using shift+F6 key. You should run your project once by pressing F6 key only then the netbeans gives option to select main class then after that clean and build.
I have finished a project - jave applet - for a friend. To run the project I am simply clicking Run Application within eclipse. How do I convert my project into 1 file, such that my friend can simply open that one file and the applet will start?
just export your project as a jar, either directly through eclipse or by using something like Ant.
Then your friend just puts the following code in their html...
<applet code="yourMainClass.class" archive="yourArchive.jar" codebase="yourCodebase/">
To reiterate, you create a Jar file which is done in Eclipse using the Export wizard. Press the File menu then the Export sub-menu, then follow the instructions:
Select Jar them Next
Select the needed files and resources, create a Jar file name, then press Next
Select options, then Next
Select a main class -- I know this is important for a desktop application, but I'm not sure if it's needed for applets.
The easiest way is to use eclipse export option.
Go to File->Export->Java (from list) -> Runnable JAR File (if you dont have it use JAR File instead)->Choose the project you want -> Choose Destination folder -> Finish.
In the folder you have choosen, will be a .jar file.