Results 1 to 3 of 3
  1. #1
    marchello is offline Member
    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Default creating a jar file

    Hi all,

    I'm very new to java, tried to write my first program and it works.

    I typed in notepad:

    //A Very Simple Example
    class ExampleProgram {
    public static void main(String[] args) {
    System.out.println("I'm a Simple Program");
    }
    }

    saved it as ExampleProgram.java

    and then compiled it using

    javac ExampleProgram.java

    Now I can run it:

    java ExampleProgram

    and it displays text "I'm a Simple Program".

    Now the question is - how do I run my program without typing "java [program name]" ? I mean, I'd like rather to run it using some kind of ExampleProgram.exe but without typing "java" before program name.

    So I've changed directiory to

    C:\oracle\Middleware\jdk160_24\bin

    created manifest file

    echo Main-Class: ExampleProgram >manifest.txt

    created my jar file

    jar cvfm ExampleProgram.jar manifest.txt ExampleProgram.class

    tried to test result by running my program

    ExampleProgram.jar

    (It doesn't return any result in command line).

    But when I run "java ExampleProgram" it does display "I'm a Simple Program"

    What I'm doing wrong now?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default Re: creating a jar file

    When you run the jar through the command line, do you get any error messages?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: creating a jar file

    You can't run it by just using the jar file name (as I'm sure someone at OTN will tell you, if they haven't already, on your thread there).
    The command to run it on the command line is:
    java -jar ExampleProgram.jar

    You can, however, double click the jar file...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Creating a XML file
    By Solid Snake in forum XML
    Replies: 3
    Last Post: 04-06-2012, 07:43 PM
  2. Creating .Jar File?
    By Alerhau in forum New To Java
    Replies: 9
    Last Post: 08-11-2011, 10:00 PM
  3. Replies: 2
    Last Post: 05-26-2011, 05:38 AM
  4. Creating jar file
    By Heather in forum Advanced Java
    Replies: 4
    Last Post: 02-11-2009, 09:58 AM
  5. creating .ear file
    By psn in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 01-06-2008, 05:01 AM

Tags for this Thread

Posting Permissions

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