Running exe files from java applications
Hello All,
Is it possible to run executable files from java applications?
I need to run an exe file on the client from the server machine, the exe could reside on either the server or any other machine on the LAN. Is it possible to specify the path of where the exe resides, and run it on a client machine?
HI,
I tried to launch a MS Word application using runtime.exec but it gives me some problem
The foll. code to launch a txt file using notepad works.
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = {"notepad.exe","C:\\coo7\\wizard.txt"};
Process child = rt.exec(callAndArgs);
However, oif I try to launch a MS Word application, it asks for the entire path of WINWORD.exe, (unlike just specifying notepad.exe as the first argument in String[] callAndArgs) and this can vary from one machine to another.. how do I get around this?
The foll. code snippet works but the complete path of where WINWORD.exe might be installed on any machine, is not fixed:-(
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = {"C:\\Program Files\\Office\\Office10\\WINWORD.exe","C:\\coo7\\wizard.doc"};
Process child = rt.exec(callAndArgs);
Any idea/suggestions pls..
Similar Messages
-
Running .EXE file from Java
Do you know, how run an .exe file, for example Internet Explorer or other program, from Java application?
It's very important for me.Too run external program and pass string arguments see class java doc
of java.lang.Runtime method exec . You see online or download or
rename src.jar to s.zip EXTRACT and see
exec
public Process exec(String[] cmdarray,
String[] envp)
throws IOException
Executes the specified command and arguments in a separate process with the
specified environment.
This is a convenience method. An invocation of the form exec(cmdarray, envp)
behaves in exactly the same way as the invocation exec(cmdarray, envp,
null).
Parameters:
cmdarray - array containing the command to call and its arguments.
envp - array of strings, each element of which has environment variable
settings in the format name=value, or null if the subprocess should inherit
the environment of the current process.
Returns:
A new Process object for managing the subprocess
Throws:
SecurityException - If a security manager exists and its checkExec method
doesn't allow creation of the subprocess
IOException - If an I/O error occurs
NullPointerException - If cmdarray is null, or one of the elements of
cmdarray is null, or one of the elements of envp is null
IndexOutOfBoundsException - If cmdarray is an empty array (has length 0)
See Also:
ProcessBuilder
getRuntime
public static Runtime getRuntime()
Returns the runtime object associated with the current Java application.
Most of the methods of class Runtime are instance methods and must be
invoked with respect to the current runtime object.
Returns:
the Runtime object associated with the current Java application. -
Running exe files from java progam
hi friends
I just want to know how can i run a .bat or .exe file in windows from a java program...
also i would like to know if i can check if mysql is installed in a windows computer from my java program
Thanks
Mustafasmshiraz wrote:
thanks Jos
now i am able to execute the .bat file.....from my java program
Can you also please tell me how can i check from my java program how if a particular application is installed in my windows computer??The exec() call will more than likely fail if the application is not present; again, read the API documentation.
kind regards,
Jos -
Running .bat files from java applications
Has anyone tried to run a .bat file from a java application?
I know I can run java commands by getting the application's runtime, but I've a number of *.bat files I like to run from the application without having to extract the commands from the .bat files.
thks,Crikey! You were answered very shortly after you posted your question, and you STILL haven't bothered to come back. And are you going to create a new userid the next time you ask a question, since bat2004 seems tied to this particular question?
-
Problem in Running EXE file from Java
Hello Friends,
I am calling an EXE program from my JSP page using Runtime.exec() method. The exe file simply reads a file and writes the content into another file (like copying a file). Now if I am providing fully qualified path to both source and destination files, then it runs absolutely fine. However, if i don't mention file path (only fine name is there), it creates output file in System32 folder and the resultant file doesn't contain any data.
I am providing the source for the EXE file.
==============
Source 1 (with fully qualified path name)
#include <stdio.h>
#include <fstream.h>
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
void write_temp_file1(char *);
void main()
char * myTempPath=NULL;
myTempPath=(char *)calloc(100,sizeof(char));
strcpy(myTempPath,"D:\\temp\\tempFile.txt");
write_temp_file1(myTempPath);
myTempPath=NULL;
void write_temp_file1(char * fileName)
// first read the file and write another file with same content
char * line1=NULL;
char * line2=NULL;
char * line3=NULL;
line1=(char *)calloc(100,sizeof(char));
line2=(char *)calloc(100,sizeof(char));
line3=(char *)calloc(100,sizeof(char));
ifstream inf;
inf.open(fileName,ios::nocreate);
inf>>line1;
inf>>line2;
inf>>line3;
inf.close();
ofstream outf;
strcat(fileName, "1");
outf.open(fileName);
outf<<line1<<endl;
outf<<line2<<endl;
outf<<line3<<endl;
outf.close ();
================================
Scenario 2 (with file name only)
#include <stdio.h>
#include <fstream.h>
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
void write_temp_file1(char *);
void main()
char * myTempPath=NULL;
myTempPath=(char *)calloc(100,sizeof(char));
strcpy(myTempPath,"my_temp_from_exe.txt");
write_temp_file1(myTempPath);
myTempPath=NULL;
void write_temp_file1(char * fileName)
// first read the file and write another file with same content
char * line1=NULL;
char * line2=NULL;
char * line3=NULL;
line1=(char *)calloc(100,sizeof(char));
line2=(char *)calloc(100,sizeof(char));
line3=(char *)calloc(100,sizeof(char));
ifstream inf;
inf.open(fileName,ios::nocreate);
inf>>line1;
inf>>line2;
inf>>line3;
inf.close();
ofstream outf;
strcat(fileName, "1");
outf.open(fileName);
outf<<line1<<endl;
outf<<line2<<endl;
outf<<line3<<endl;
outf.close ();
==========================
Can anyone figure out what could be the problem ? I think there is a problem with Library Path or sort of something like that.
Please help me.
-- Niranjanproviding source code for the EXE program doesn't tell your problem.
You have to be more specific. What is your problem? -
How to create the exe files for java application
How to create the exe file for java application?
got any software to do that?
ThanksIn terms of converting java applications into exe files, there are 3 schools of thought:
1) Instead of converting it to an exe, convert it to a jar file. Jar files are more portable than exe files because they can be double-clicked on any operating system. The caveat is that a Java interpreter must be installed on the target computer for the double-clicking to work.
http://developer.java.sun.com/developer/Books/javaprogramming/JAR/
2) Create an exe launcher that, when double-clicked, attempts to find a Java interpreter on the local computer and launches the Java application. The exe file is still double-clickable but whether your java application runs depends on whether a Java interpretor is installed on the target computer.
http://www.sureshotsoftware.com/exej/
http://www.objects.com.au/products/jstart/index.jsp
http://www.duckware.com/products/javatools.html
http://www.ucware.com/jexec/
http://www.rolemaker.dk/nonRoleMaker/javalauncher/
http://www.jelude.cjb.net/
http://thor.prohosting.com/~dfolly/java/index.html
3) Create an exe launcher that bundles a Java interpretor. Same as above but when the exe file is double-clicked, it searches for a Java interpreter and if one is not found, it installs one on the target computer. The caveat is that the exe file would have an overhead of 10 MB in size for the interpreter.
http://www.excelsior-usa.com/jet.html (evaluation version available)
4) Convert the Java application into a native exe file. The caveat is that if you use Swing for your GUI, it won't be converted. Also this option is still somewhat experimental.
Can't think of any free options right now. -
Hi all !!!
Is it possible to run a *.exe file from java.....
if yes how??
if no why not??
regards
adYes. It's possible. One of the Runtime.exec() methods are probably what you want:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
You can't instantiate a Runtime object, so you'll need to call it up by:
Runtime.getRuntime()
For example, if you want to run the Calculator in Windows, try:
Runtime.getRuntime().exec("calc"); -
How to run ear file in java application server
i want how to run .ear file in java application server
1. i m created ear file
2. i m created jar file (bean,home,remote)
3.i m created war file(in the form of jsp)
but till now i couldnt run ear file
how to run
please hel meYou must create :
1.Jar file
2.War file
And then put them into an ear file
Exemple : myapp.ear contains
myappEJB.jar
myappWEB.war
META-INF/application.xml
and application.xml looks like this :
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>myapp</display-name>
<description>Demo application</description>
<module>
<ejb>myappEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>myappWAR.war</web-uri>
<context-root>/myapp</context-root>
</web>
</module>
</application>Good luck -
Running .nsi file from java
hi,
Ho to run .nsi file from java.
thanks in advance.User845466 wrote:
Ho to run .nsi file from java.Find the program hanling that kind of documents an launch this via Runtime.exec() giving it your *.nsi file as a parameter.
bye
TPD -
I wants to call .Exe file from Java Programme
I wants to call .Exe file from Java programme. Please give answer with example. This very urgent. Help me
hi
u can use Runtime.exec() method in java.lang package
to execute exe files
regards
pnp -
Can we run EXE file/ Another Java Program from Java Application? How?
Can we run EXE file and another java program from java application?
Thanks in advanceExample running adobe acrobat
String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
Runtime rn = Runtime.getRuntime();
Process process = rn.exec(command);
process.waitFor();rykk -
Hi , can anyone tell me how to run an exe file from my java program. the exe is in the same directory as my java files . When i click on a button i want to put something in the actionPerformed() method which will launch the exe file - prog.exe
Hope someone can help me.
Thanks JimHi !
Look at the RunTime class... -
How to run exe file from inside java
I wan to run an exe file from inside java code. How can I do it?
ThanksHi Oakam
This is very simple. Just go through the given code below
in place of FILEANDPATHNAME just give the exe's path and name
Note :- adding ".exe " is not necessary
public class exep
public static void main(String args[])
Runtime r = Runtime.getRuntime();
Process p = null;
try{
p = r.exec("FILEANDPATHNAME");
catch(Exception e)
Give ur feedback
Thanx
Ottran -
Error running batch files from java source file???
Dear Friends,
hi,
this is with response to a doubt i had earlier ,
i want to run batch files from the java source file ,i tried using this code (here batrun is the batch file name that contains commands to run other java files)
try
String [] command = {"c:\\vishal\\finalmain\\batrun"};
Runtime.getRuntime().exec(command);
catch(Exception e)
but i got the following error.
java.io.IOException: CreateProcess: gnagarrun error= 2
plz. help me, i tried all combination w/o success,
in anticipation(if possible give the code after testing)
Vishal.hello there,
i solved the prob. by using
cmd /c start filename ,but i need to pass parameters ie
cmd /c start java "c:/vishal/runfile a b" where a and b are the parameters. but it is not accepting this in Runtime.getRuntime.exec(),
any solutions ?????????
regards,
Vishal -
hi all
i am looking for code to run a program(any EXE File ) from developer Form (Developer 6i)
thanks a lotlook at the documentation for the HOST command in Forms.
Regards
Grant Ronald
Forms Product Management
Maybe you are looking for
-
Deployment of web services in 11.1.1.3.0
Hi , I created the pl/sql web services successfully and when I am trying to deploy those in weblogic server its not deploying saying that deployment failed Fallowed by java errors - Please Advice me the Steps to deploy the web services. Thanks
-
1841 Load Balancing and Failover
I have an 1841 router with a HWIC-4ESW (4port switch) card installed. The 4ESW is setup as VLAN1 and serves the internal network as the default gateway. The FE0/0 and FE0/1 interfaces are each connected to a ADSL Router. I currently have one WAN inte
-
Updating to 7.10 disabled viewing pdf in browser
updating to 7.10 disabled viewing pdf in web browser which is working normally in 7.09 no matter settings in preference, internet, are all marked to view pdf in browser and allow fast web view etc, every pdf links are opened in a new acrobat window w
-
Problem in barcode printing..
I am given only the barcode dimension and content to print it using smartforms..how do i go about it..? Do i have to start from SPAD transaction or se73.. kindly let me know links which may give step by step guideline to my problem..and in SE73 i don
-
Install Illustrator CS2 on Machine w/ CS3 Suite?
Hi, we have one computer that has the full CS3 suite installed on it only. It is running Leopard from a clean install. We just found out that Illustrator dropped support for AutoCad files (that's just great!) in CS3, so we need to install a version o