Is JDK required to run a jar file?

Discussion in 'Java' started by Grzesiek, Aug 19, 2007.

  1. Grzesiek

    Grzesiek Guest

    Hi,
    I have the following problem. I creted App.jar file. In App.java i
    have a line:

    Runtime.getRuntime("java -jar DoIt.jar");

    Now i want to run App.jar on a computer wher\e there is only JRE and
    no JDK, so "java" command is unknown. Is it possible to run App.jar
    using only JRE? If not, how should i change the line above?

    Thanx
     
    Grzesiek, Aug 19, 2007
    #1
    1. Advertising

  2. Grzesiek

    Lew Guest

    Grzesiek wrote:
    > Hi,
    > I have the following problem. I creted App.jar file. In App.java i
    > have a line:
    >
    > Runtime.getRuntime("java -jar DoIt.jar");
    >
    > Now i want to run App.jar on a computer wher\e there is only JRE and
    > no JDK, so "java" command is unknown. Is it possible to run App.jar
    > using only JRE? If not, how should i change the line above?


    "java" is a command in the JRE.

    Most folks use all lower-case letters for JAR names. This is not so much a
    matter of convention as of laziness, but it is widespread. However, the word
    "I" in English should always be spelled with an initial upper-case letter.

    Try using the right method of the Runtime class. The line you show will not
    compile, because getRuntime() does not take an argument. Have you read the
    Javadocs?
    <http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#getRuntime()>

    Read the Javadocs on the various Runtime exec() methods. And next time,
    prepare an SSCCE (Simple Self-Contained Correct (compilable) Example) that
    evinces your difficulty. The act of preparing it and reviewing its error
    message(s) will likely show you the trouble and its solution on your own.

    <http://www.physci.org/codes/sscce.html>

    If you had done that, you'd've seen right away that your version of
    getRuntime() won't compile, and the error message would've told you why.

    --
    Lew
     
    Lew, Aug 19, 2007
    #2
    1. Advertising

  3. Grzesiek

    Kunkhmer Guest

    On Aug 19, 10:20 pm, Grzesiek <> wrote:
    > Hi,
    > I have the following problem. I creted App.jar file. In App.java i
    > have a line:
    >
    > Runtime.getRuntime("java -jar DoIt.jar");
    >
    > Now i want to run App.jar on a computer wher\e there is only JRE and
    > no JDK, so "java" command is unknown. Is it possible to run App.jar
    > using only JRE? If not, how should i change the line above?
    >
    > Thanx



    Try this line.
    Runtime.getRuntime().exec("java -jar DoIt.jar")
    No JDK needed
     
    Kunkhmer, Aug 19, 2007
    #3
  4. Grzesiek wrote:
    > I have the following problem. I creted App.jar file. In App.java i
    > have a line:
    >
    > Runtime.getRuntime("java -jar DoIt.jar");
    >
    > Now i want to run App.jar on a computer wher\e there is only JRE and
    > no JDK, so "java" command is unknown.

    Your conclusion is wrong. The "java" command *is* part of the JRE.

    For example on my Windows, the JRE 1.5.0_10 is installed in
    "C:\Programme\Java\jre1.5.0_10\". The java command of this JRE is
    "C:\Programme\Java\jre1.5.0_10\bin\java.exe".
    There is no need for any JDK to be installed to run your java
    application. On the other hand: a JRE doesn't contain any development
    tools (like "javac.exe", "jar.exe", ...).

    However, if you have a JDK installed, you'll have a second JRE inside
    that. For example on my Windows, the JDK 1.5.0_10 is installed in
    "C:\Program Files\Java\jre1.5.0_10\". It contains a complete JRE in
    "C:\Program Files\Java\jre1.5.0_10\jre\". Especially, there is a java
    command in it: "C:\Program Files\Java\jre1.5.0_10\jre\bin\java.exe".

    > Is it possible to run App.jar using only JRE?

    Yes.


    --
    Thomas
     
    Thomas Fritsch, Aug 19, 2007
    #4
  5. Thomas Fritsch wrote:
    > Your conclusion is wrong. The "java" command *is* part of the JRE.
    >
    > For example on my Windows, the JRE 1.5.0_10 is installed in
    > "C:\Programme\Java\jre1.5.0_10\". The java command of this JRE is
    > "C:\Programme\Java\jre1.5.0_10\bin\java.exe".
    > There is no need for any JDK to be installed to run your java
    > application. On the other hand: a JRE doesn't contain any development
    > tools (like "javac.exe", "jar.exe", ...).
    >
    > However, if you have a JDK installed, you'll have a second JRE inside
    > that. For example on my Windows, the JDK 1.5.0_10 is installed in
    > "C:\Program Files\Java\jre1.5.0_10\". It contains a complete JRE in
    > "C:\Program Files\Java\jre1.5.0_10\jre\". Especially, there is a java
    > command in it: "C:\Program Files\Java\jre1.5.0_10\jre\bin\java.exe".

    Oops, I meant to write:
    on my Windows, the JDK 1.5.0_10 is installed in
    "C:\Program Files\Java\jdk1.5.0_10\". It contains a complete JRE in
    "C:\Program Files\Java\jdk1.5.0_10\jre\". Especially, there is a java
    command in it: "C:\Program Files\Java\jdk1.5.0_10\jre\bin\java.exe".
    Sorry for the confusion.


    --
    Thomas
     
    Thomas Fritsch, Aug 19, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    610
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,767
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,843
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    689
    Arnold Peters
    Jan 5, 2005
  5. Dundonald
    Replies:
    8
    Views:
    1,401
    Mike Schilling
    Oct 5, 2007
Loading...

Share This Page