Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

Is JDK required to run a jar file?

Thread view: 
Grzesiek - 19 Aug 2007 13:20 GMT
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
Lew - 19 Aug 2007 13:35 GMT
> Hi,
> I have the following problem. I creted App.jar file. In App.java i
[quoted text clipped - 5 lines]
> 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.

Signature

Lew

Kunkhmer - 19 Aug 2007 15:10 GMT
> Hi,
> I have the following problem. I creted App.jar file. In App.java i
[quoted text clipped - 7 lines]
>
> Thanx

Try this line.
Runtime.getRuntime().exec("java -jar DoIt.jar")
No JDK needed
Thomas Fritsch - 19 Aug 2007 17:49 GMT
> I have the following problem. I creted App.jar file. In App.java i
> have a line:
[quoted text clipped - 3 lines]
> 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.

Signature

Thomas

Thomas Fritsch - 19 Aug 2007 17:53 GMT
> Your conclusion is wrong. The "java" command *is* part of the JRE.
>
[quoted text clipped - 10 lines]
> "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.

Signature

Thomas



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.