beginner to java - how to run outside jcreator/netbeans ?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: beginner to java - how to run outside jcreator/netbeans ?

  1. #1
    Join Date
    Dec 2005
    Posts
    4

    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?

  2. #2
    Join Date
    Oct 2004
    Location
    Chicago
    Posts
    108
    I think you can create executable .jar files

    http://java.sun.com/docs/books/tutorial/jar/basics/

    I hope this helps

  3. #3
    Join Date
    Oct 2005
    Posts
    107
    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

  4. #4
    Join Date
    Dec 2005
    Posts
    4
    cool thanks for your help, ill give it a try

  5. #5
    Join Date
    Dec 2005
    Posts
    4
    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?

  6. #6
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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.

  7. #7
    Join Date
    Oct 2005
    Posts
    107
    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.
    Last edited by Joe Beam; 12-04-2005 at 02:13 PM.

  8. #8
    Join Date
    Sep 2005
    Posts
    16
    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.

  9. #9
    Join Date
    Dec 2005
    Posts
    4
    Alright, thanks everyone for all your help. Ill give it another try.

Similar Threads

  1. Replies: 2
    Last Post: 06-14-2006, 04:16 PM
  2. Replies: 4
    Last Post: 08-18-2005, 11:33 AM
  3. Has Sun Given Up on the Desktop?
    By Lori Piquet in forum Talk to the Editors
    Replies: 114
    Last Post: 10-10-2002, 07:01 AM
  4. Run java servers as windows services
    By Sergio Pereira in forum Java
    Replies: 3
    Last Post: 05-25-2001, 05:19 PM
  5. Best Java Development environment
    By H. Wilson in forum Java
    Replies: 6
    Last Post: 04-14-2000, 12:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center