472,809 Members | 3,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,809 software developers and data experts.

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 20293
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: vishal | last post by:
hi how can i get the file name from which the current executing file is called. i m making a scrript which will be called from many other scripts. this script performs some calculation and then...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
15
by: (Pete Cresswell) | last post by:
I've got a .BAT file that I use for executing various MS Access apps that I wrote way back in the days of 2.0. It's evolved over time, but it still contains a number of possible paths to...
4
by: Sampriti | last post by:
I am trying to delete a file from a disk when the user's session ends. So I am putting my file.delete code in Session_End event. I ran the application in the debug mode. When the session timesout...
7
by: Jibey | last post by:
Hello: I'm facing a very strange problem. When I run my Web application in Visual Studio.NET the Page_Load event is not executing. Other events like a Button_Click are executing. It doesn't...
0
by: Roshawn Dawson | last post by:
Hi, I have a web application that has various sub directories. Here is what it looks like: MyApp/default.aspx MyApp/Author/default.aspx MyApp/xslt/books.xsl
7
by: David R. | last post by:
Hello all, I would like to generate a Sql-Script-File and a Batch-File to execute the Batch-File over C#-Code and use the SQL-File as an Input-File for the command "osql" in the Batch-File. I...
7
by: tshad | last post by:
I thought I understood how the SaveViewState is working and was trying to use this (as per some code I found) to detect refreshes. It seemed to be working but I found that the SaveViewState was...
8
by: lovecreatesbea... | last post by:
K&R 2, sec 2.4 says: If the variable in question is not automatic, the initialization is done once only, conceptually before the program starts executing, ... . "Non-automatic variables are...
2
by: RaviRajhulk | last post by:
I have tried executing executing a batch file from a perl code using system("start c:\\temp\\sample.bat") but it is not executing ,Is there any way to execute batch file from a perl code
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.