469,290 Members | 1,887 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Executing a jar file

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
5 20093
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
>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
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

"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
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.

Similar topics

15 posts views Thread by (Pete Cresswell) | last post: by
7 posts views Thread by Jibey | last post: by
reply views Thread by Roshawn Dawson | last post: by
7 posts views Thread by tshad | last post: by
8 posts views Thread by lovecreatesbea... | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.