By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

Executing a jar file

P: n/a
Che
I have the following code
/*

WinTest.java

*/

import java.io.*;
public class WinTest {
public static void main (String args[]) {

String line;
Process backgroundProcess;

try {

// Start the other process
backgroundProcess = Runtime.getRuntime().exec
("d:\\program files\\cprog.exe");
}
catch (Exception e) {

System.out.println(e);
}
}
}
If I execute the class file from a cmd windown I get the start up
screen from the cprog.exe, however as I would like to dispense with
the dos window I packaged the class into a jar file

First creating a text file called WinTest.txt containin the single
line

Main-Class: WinTest

Then create the jar file

jar cmf WinTest app.jar WinTest.class

I associated the jar file with the java.exe in the SDK lib

But when I double click to execute the jar file a dos window pops up
disappears but no start screen from the cprog.exe is shown

I'm sure it is a severe user error must I have to admit to being
stumped and help would be nuch appreciated
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
In article <68**************************@posting.google.com >,
st***@cheguevara.zzn.com (Che) wrote:
I associated the jar file with the java.exe in the SDK lib

But when I double click to execute the jar file a dos window pops up
disappears but no start screen from the cprog.exe is shown


I don't know if the tools work the same on windows (I assume they do),
but on unix you execute such a file with the command "java -jar
file.jar". So I guess on windows maybe you need to add the "/jar" switch?

-Chad
Jul 17 '05 #2

P: n/a
>So I guess on windows maybe you need to add the "/jar" switch?

no it's "java -jar File.jar" on windows as well


Jul 17 '05 #3

P: n/a
Che wrote:

I associated the jar file with the java.exe in the SDK lib

But when I double click to execute the jar file a dos window pops up
disappears but no start screen from the cprog.exe is shown

I'm sure it is a severe user error must I have to admit to being
stumped and help would be nuch appreciated


Open a DOS prompt in the directory containing your jar file. Enter the
jar file as if it were a command. This will execute the jar file in the
same manner as double-clicking. The difference is that the DOS window
will not immediately disappear and you may get some useful information.

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 17 '05 #4

P: n/a

"Raymond DeCampo" <rd******@spam.twcny.spam.rr.spam.com.spam> wrote in
message news:vP*******************@twister.nyroc.rr.com...
Che wrote:

I associated the jar file with the java.exe in the SDK lib

But when I double click to execute the jar file a dos window pops up
disappears but no start screen from the cprog.exe is shown

I'm sure it is a severe user error must I have to admit to being
stumped and help would be nuch appreciated


Open a DOS prompt in the directory containing your jar file. Enter the
jar file as if it were a command. This will execute the jar file in the
same manner as double-clicking. The difference is that the DOS window
will not immediately disappear and you may get some useful information.


Or for the above you can change javaw.exe to java.exe under
explorer|tools|file type extensions| jar|edit ...

Gives the same result.

Jul 17 '05 #5

P: n/a
st***@cheguevara.zzn.com (Che) wrote in message news:<68**************************@posting.google. com>...
I associated the jar file with the java.exe in the SDK lib

But when I double click to execute the jar file a dos window pops up
disappears but no start screen from the cprog.exe is shown


The .jar extension should be associated with javaw.exe. You shouldn't
get a dos window at all this way, even for a split second. In fact,
when you installed the Java SDK, this association should have been
made automatically by the installer.

I don't know if changing this will fix the problem of cprog.exe not
being launched, though.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.