Hi everyone,
I am new to these forums, I've been looking for an answer to this question for awhile so hopefully someone can help me out.
I am relatively new to programming, I know my way around but have a lot to learn. I wrote a program the past two days to help me study my AP Chem terms so I can memorize them. The program is now fully functional and runs in Eclipse when i hit run. My question is how can i make my program run OUTSIDE of eclipse? I want to be able to make a .jar (or whatever is best) so that i can double click it and open it up. I assume it would have to use a command prompt or something (the program is ALL text, no jframes or anything like that) When I try to export it as a .jar file and run it, it shows up saying it failed to load the main class manifest and can't start. How can I make the program work? again all i want is to open a command prompt or something like that that displays text and allows user input of text. Hopefully you all understand what I am asking (It's difficult to describe). Please respond with your thoughts. Thanks again!
it shows up saying it failed to load the main class manifest and can't start.
To execute a program in a jar file via the double click on the file, you need to have the OS execute the java command with the -jar option. The jar file must contain a manifest file with a Main-Class: record that refers to the class with the main() method that will start the program. Your IDE can be configured to generate all that.
To get a console window, try making a batch file that will execute the jar file. Then create a shortcut that will execute the batch file.
The .java file im making into a jar starts with this (showing it has a main() )
public class CalcReview {
public static void main(String[] args) {
the .jar ONLY contains this file, there arent multiple .java files in it. so it has the main() in it already right? Forgive me, I'm new to all of this. As for the batch file, I would have no clue how to do that either =/ ill try to google it to find out more about it
i SEEM to have made some progress....i exported it differently and don't get the failed to find manifest error. I can't get the batch file to run. I type java -jar Myjar.jar and it returns that java is not recognized as an internal or external command. However that format is the only one i've found.....can you please recommend to me how to make a simple batch so it'll work?
Can you copy the console here from when you try to execute it?
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
This is from the CMD.
More information: When i export out of eclipse, I let it generate the manifest in CalcReview/bin/manifest (calcreview being the project of the jar). I don't know if this is wrong or not...I got the batch file working too. Everything now says invalid or corrupt jar file
Bookmarks