This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes exe of a jar file + passing parameter from cmd prompt to exe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "exe of a jar file + passing parameter from cmd prompt to exe" Watch "exe of a jar file + passing parameter from cmd prompt to exe" New topic
Author

exe of a jar file + passing parameter from cmd prompt to exe

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753
Hi,

can we create an EXE of a jar file. the extension should be exe for Eg : testJar.exe

and can we pass parameter to the exe from comand prompt

for Eg :

C:\tesJar.exe 9969413222 Jigar

the functionality of the testJar.exe is to get the parameter and log it into the file system.

can it be possible ?

Thanks & Regards.
Jigar Naik


Jigar Naik


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41151
    
  45
You can create a batch file (a.k.a. shell script) that runs the jar file and passes in whatever parameters it received.

Or is the objective to create native code?


Ping & DNS - my free Android networking tools app
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753
well we have another application which was written in C++ which has opetion in GUI for executing .exe files.

so batch wont work. plus we have to pass arguement to exe. at run time.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

You can call java.exe or javaw.exe:

If it is a windowed application use javaw.exe, otherwise use java.exe

If you need the full path to java.exe, you can use %WINDIR%\system32 as the path, which usually translates to C:\WINDOWS\system32


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 753
Hey Rob,

Thanks a lot, I think that should work fine.

Regards,
Jigar Naik
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: exe of a jar file + passing parameter from cmd prompt to exe
 
Similar Threads
Problem after making an application using JDBC
Running a .exe file from a .java file
How to create exe file
Security of Java Jar file
how to convert java file in to exe. file ..........