beginner to java - how to run outside jcreator/netbeans ?
Hello everyone,
Im a beginner to Java, started in university this year. I was wondering how a java application can be run outside the IDE, say, by clicking an icon? I know it can be run in the command prompt, are there other ways?
# 1 Re: beginner to java - how to run outside jcreator/netbeans ?
I think you can create executable .jar files
http://java.sun.com/docs/books/tutorial/jar/basics/
I hope this helps
# 2 Re: beginner to java - how to run outside jcreator/netbeans ?
quick way to do this...
1. make a txt file called say 'mc.mf' at the root of your application
2. open the file and enter: 'Main-Class: Driver' on the first line where Driver is the name of your class that contains the main method.
3. create a jar file like so: 'jar cvfm thejar.jar mc.mf *.class' replace thejar.jar with the name you want.
4. now simply double click the jar and it runs that main method
# 3 Re: beginner to java - how to run outside jcreator/netbeans ?
cool thanks for your help, ill give it a try
# 4 Re: beginner to java - how to run outside jcreator/netbeans ?
I tried what you said above, but I got an error message saying:
Failed to load Main-Class manifest attribute from C:\Bluff\bluff.jar
Its a java application called bluff, a card game.
Any ideas?
# 5 Re: beginner to java - how to run outside jcreator/netbeans ?
Have you tried opening a "DOS window" - or other operating system command window, and just typing "java THENAMEOFYOURCLASSWITHMETHODMAIN" ? This is a problem with starting your introduction to Java by using an IDE - you don't learn to work outside of the boundary of the IDE.
nspils at 2007-11-11 22:42:34 >

# 6 Re: beginner to java - how to run outside jcreator/netbeans ?
It looks like it can't find the class you entered in the manifest file. In your manifest file it should be...
Main-Class: 'The name of the class that contains your main method without the .class'
i.e.
Main-Class: Driver
then recreate the jar...Also make sure you have jarred all the classes you need especially the main-class one... ;) hmmm does anyone else sayed jarred? :)
I agree with nspils... I started out doing all my programming from command line with Unix. Then moved on too different fancy IDE's with a better understanding in place.
# 7 Re: beginner to java - how to run outside jcreator/netbeans ?
If you're using Netbeans, then all you have to do is press F11 to build the project. Then, in your project folder/dist/ will exist a .jar file with the name of your project. Just double click that jar and it will execute the classes itself.
This would be the alternative of creating .jar files manualy... if you use netbeans.
# 8 Re: beginner to java - how to run outside jcreator/netbeans ?
Alright, thanks everyone for all your help. Ill give it another try.