Results 1 to 10 of 10
  1. #1
    Etimer is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default How could I make this work in Executable JAR File?

    Java Code:
    package practice;
    
    public class variables1 {
    	public static void main(String[] args){
    		System.out.print("Hello");
    	}
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: How could I make this work in Executable JAR File?

    What problems are you having? Does the manifest file identify this class as the one with the application's entry point, the Main-Class?

  3. #3
    Etimer is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default Re: How could I make this work in Executable JAR File?

    Umm.. i'm not exactly sure, but it works in eclipse and shows the text "Hello" in the console like it should, but when i export it to the desktop, the file doesnt run when i click it

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: How could I make this work in Executable JAR File?

    When you click it you will never see if it runs since you don't create a long-standing console window. If you're in Windows, create a console via cmd.exe, and run your jar file from there.

  5. #5
    Etimer is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default Re: How could I make this work in Executable JAR File?

    Ok, and how exactly can i do that?
    Sorry for not knowing this.. :/

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  7. #7
    Etimer is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default Re: How could I make this work in Executable JAR File?

    I looked at that page but didn't really understand much of it.
    I dont know what type of file this would be, but I CAN tell you what i want to do.


    Here's what i want to do:

    I made a new project and made a new class in that.
    I wrote this code into that class:
    Java Code:
    package practice;
    
    public class variables1 {
    	public static void main(String[] args){
    		System.out.print("Hello");
    	}	
    }
    It runs and shows the message "Hello" on the console in Eclipse.


    Here's where I don't know what to do:

    I don't know how to make that file into some file in a folder that can be clicked on, and open a window that shows the message "Hello" and closes when i click X.

    That's what i want to do.


    Thanks alot
    Last edited by Etimer; 02-05-2012 at 12:15 AM.

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: How could I make this work in Executable JAR File?

    The simplest solution is to display your output with a JOptionPane:

    Java Code:
    import javax.swing.JOptionPane;
    
    public class HelloWorld {
       public static void main(String[] args) {
          JOptionPane.showMessageDialog(null, "Hello World");
       }
    }
    Then use Eclipse's export wizard to create a jar file that holds this file, but making sure to set the Main class in the export wizard to this class.

    Then if your OS has been configured correctly, double clicking on the jar file will run the class and show the option pane.

  9. #9
    Etimer is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default Re: How could I make this work in Executable JAR File?

    Thank you very much!
    Not only did you help me out, but you gave me a valuable tip(the dialogue box thing).

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: How could I make this work in Executable JAR File?

    You're welcome!

Similar Threads

  1. Allow YOUR work to make a DIFFERENCE!!
    By erictgroup in forum Jobs Offered
    Replies: 0
    Last Post: 06-02-2011, 12:19 AM
  2. Make it work !
    By PhQ in forum New To Java
    Replies: 6
    Last Post: 09-20-2010, 09:22 AM
  3. How do i make this work What am i doing Wrong.
    By Ramaan in forum New To Java
    Replies: 2
    Last Post: 03-02-2010, 12:36 AM
  4. Make the Button Work
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 1
    Last Post: 02-27-2010, 11:52 AM
  5. Can't make JTable work -- please help!!
    By cagalli83 in forum Advanced Java
    Replies: 0
    Last Post: 02-13-2008, 10:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •