How to execute another application from java ?
I want to execute another application ( not java ) from my java application. Is it possible ? How can we do it ? Please guide me...
thanx
Hi littlestuart,
Yes it's possible.
Your question is frequently asked, please search the forum or google for an answer.
/Kaj
Similar Messages
-
How to execute Linux command from Java app.
Hi all,
Could anyone show me how to execute Linux command from Java app. For example, I have the need to execute the "ls" command from my Java app (which is running on the Linux machine), how should I write the codes?
Thanks a lot,You can use "built-in" shell commands, you just need to invoke the shell and tell it to run the command. See the -c switch in the man page for your shell. But, "ls" isn't built-in anyays.
If you use exec, you will want to set the directory with the dir argument to exec, or add it to the command or cmdarray. See the API for the variants of java.lang.Runtime.exec(). (If you're invoking it repeatedly, you can most likely modify a cmdarray more efficiently than having exec() decompose your command).
You will also definitely want to save the returned Process and read the output from it (possibly stderr too and get an exit status). See API for java.lang.Process. Here's an example
java.io.BufferedReader br =
new java.io.BufferedReader(new java.io.InputStreamReader(
Runtime.getRuntime().exec ("/sbin/ifconfig ppp0").
getInputStream()));
while ((s = br.readLine()) != null) {... -
How to launch an application from java?
Hi,
Would anybody please help me this. I need to launch a new desktop application from my java app but I don't know how. For example, when user clicks on a "Edit" button from my java app, my app needs to launch NOTEPAD.EXE to allow user starts editing.
Thanks a lot.
Hung.try something like this for your button's action method:
String[] cmd = {"notepad"};
Runtime rt = Runtime.getRuntime();
try {
Process pro = rt.exec(cmd);
pro.waitFor(); // wait until it's done executing
System.out.println("Process exit code is: " + pro.exitValue());
}catch(IOException ioe) {
System.err.println("IOException -> " + ioe);
} catch(InterruptedException ie){
System.err.println("InterruptedException: " + ie);
} -
How to execute SAPgui.exe from java code
Hi All,
Can any one provide me the exe file name of SAP GUI related.
I need to call the SAP GUI related exe file from java.
i tried with a small java prog which executes the exe files.
it works fine with notepad.exe,javac.exe . But i am unable to execute the SAPgui.exe.
This is my java code
try{
Runtime rt=Runtime.getRuntime();
//String str= "C:
WINNT
system32
notepad.exe";
//Process pp=rt.exec("C:
j2sdk1.4.2_08
bin
javac");
Process pp=rt.exec("C:
Program Files
SAP
FrontEnd
SAPgui
SAPgui.exe");
BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}catch(Exception e){
System.out.println(e);
and may i pass any additional parameters inorder to invoke this exe.
Please share your ideas abt this problem.
Its Urgent PLZ
Adv Thanks
Regds
Phani.hi Rajesh,
here my complete code:
try{
Runtime rt=Runtime.getRuntime();
// String str= "C:\Programmi\SAP\FrontEnd\SAPgui\saplogon.exe";
String str= "C:\Programmi\SAP\FrontEnd\SAPgui\Sapgui.exe 10.113.10.201 00";
// Process pp=rt.exec("C:\j2sdk1.4.2_08\bin\javac");
Process pp=rt.exec(str);
BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}catch(Exception e){
System.out.println(e);
Please note that system number is only two digit and in your case is 00.
Another important think, i'm using the italian version of windows, so the program directory is c:\programmi, please change into c:\program files, or you can modify your code to be language indipendend using an system environment variable (if exist).
Hope this help
Francesco -
Execute another programm from Java
Hello Java Gurus,
I am developing a java app that reads from my DB and do some calcs with it. I would need to execute another programm later sending some of the data as parameters.
In C I would use _exec() function, is there any function like that in Java?
Many thnks,
AC.There is a method like
runtime.exec();
you could use that. -
How to execute PL/SQL from Java?
I want to execute (compile) a PL/SQL file to a database and I don't know how it can be done with Java.
Please note that I am NOT trying to call a stored procedure. I know that can be done with CallableStatement.
Background:
My actual requirement is to execute PL/SQL files with error notifications. I tried Ant SQL task; but it fails to give compilation error information. I also tried another open source task called Incanto - that also not that helpful as if I execute in bulk, very hard to figureout which one throws error. Hence I decided to write my own Ant task.Hi,
do u want to execute PL/SQL files? or just you want to execute the block of code?
in the case of PL/SQL file:
you need to read total file as StringBuffer/String and then execute.
Block of code:
you can directly pass the code to the java file as input and then execute.
Ex:
StringBuffer queryString = new StringBuffer();
queryString = queryString.append("BEGIN execute immediate ' ");
queryString = queryString.append(query);
//queryString = queryString.append("BEGIN dbms_job.run(142);END;");
queryString = queryString.append(" '; END; ");
final_Query = queryString.toString();
try {
System.out.println("final : "+final_Query);
cstmt = con.prepareCall(final_Query);
System.out.println("Job is Running...");
new ThreadCountdownExtThread().start();
System.out.println("bfore execute()...............");
cstmt.execute();Note: if you are running pl/sql file read file and save it in a Stirng , and then do the same as above stated -
How to run Other application from Java
I want to run other applications such as IE.exe, notepad.exe from Java? How can I run?
Dear Friend, the following is the code to open IExplorer from Java Program
class RunTimeTest {
public static void main(String args[]) {
try {
Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.exe");
catch(Exception e) {
[\code]
ALL THE BEST
Shiva -
How to run another concurrent from Java Concurrent Program?
Hi,
I have one Java Concurrent Program in ebs R12.
I need to run another Java Concurrent Program when first finished.
I can not find a way to start another request from JCP.
Thanks,
msHi ,
this is an example code to check the OS before running the command :
try{
int ch;
Process proc ;
Runtime r=Runtime.getRuntime();
StringBuffer sbuf = new StringBuffer();
String dir = new String();
String osname = System.getProperty("os.name");
if(osname.equals("Windows NT") )
proc = r.exec("cmd /c dir");
if(osname.startsWith("Linux") )
proc = r.exec("df -k");
InputStream is = proc.getInputStream();
while((ch=is.read() ) != -1)
sbuf.append((char)ch);
is.close();
dir = sbuf.toString();
System.out.println(dir );
}catch(Exception e){ System.out.println(e.getMessage());}
bye
Taha -
How to call msword application from java program
hai every body
i want to know about OLE in java.
how can i invoke msoffice application in java code.
if any body have sanple code for this post for me
thank youThere are some bridges available ...
http://www.google.com/search?q=ole+java+bridge -
How to open another application from a java programme
How can I open some other application like "Textpad"
from a java programme.
Actually I want to open a particular java file in Textpad editor from my java programme.
How Can I do that?
ThanksThanks for the code,
I tried that but got this error
java.io.IOException: CreateProcess: C://ProgramFiles/TextPad4/TextPad.exe D://Pi
yush/BeanCreator/Parts.java error=3
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:64)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:272)
at java.lang.Runtime.exec(Runtime.java:195)
at java.lang.Runtime.exec(Runtime.java:152)
at pack.CreateBean.CreateFile(CreateBean.java:327)
Any idea!! What that means -
How to execute .msi files from java program
Hi friends,
i have written a java program which invokes and thereby execute any executable files like .exe and .bat.
So its working fine with .exe and .bat files, but it is not working with .msi files.......can you please help me how can i execute .msi files as well??
public class Executeexe {
public static void main(String ar[])
try
Process p=null;
Runtime rt=Runtime.getRuntime();
p=rt.exec("D:\\mysql-essential-5.0.83-win32.msi");
p.waitFor();
catch(Exception e)
}here is the programMake sure that the command that's being exec'd works from the cmd line.
Then read this article and do what it says:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Then if you still are having problems explain what "...it is not working with .msi files..." really means, and provide a [SSCCE Example program|http://mindprod.com/jgloss/sscce.html] -
�How to execute a .exe from Java applicattion?
Hi, I have to play a file song with VLC(Video Lane Client) from a Java applicattion. I know how to open an external executable, but not how to open some file with it. Thanks
I don't understand very well. It is new for me.The documentation for VLC will show you what command-line options there are for controlling the player. You can use these similarly to how you would launch an executable, since you will in fact be launching an executable. Later versions of VLC also give you a telnet interface, so you can remotely control the player via a telnet connection. Combine that with some socket programming or something like apache-commons-net TelnetClient, and you can do what you're after
I can't really help much more than that, because I can't remember what the commandline options are or anything, only that they exist! -
How to execute system command from java program
Hi all,
I want to change directory path and then execute bash and other unix commands from a java program. When I execute them separately, it's working. Even in different try-catch block it's working but when I try to incorporate both of them in same try-catch block, I am not able to execute the commands. The change directory command works but it won't show me the effects of the bash and other commands.
Suggestions??The code I am using is....
try
String str="cd D:\\Test";
Process p=Runtime.getRuntime().exec("cmd /c cd
"+str);your str string is already having cd in it but again you ar giving cd as part of this command also please check this,i will suggest you to remove cd from str
Process p1=Runtime.getRuntime().exec("cmd /c mkdir
"+str+"\\test_folder");you should say mkdir once you change your path,but here you are saying mkdir first and then cd D:\Test(this is because of str)..please check this
Process p2=Runtime.getRuntime().exec("cmd /c bash");
Process p3=Runtime.getRuntime().exec("cmd /c echo
himanshu>name.txt");
catch(IOException e)
System.err.println("Error on exec() method");
e.printStackTrace();
Message was edited by:
ragas -
hi friends,Iam used mysqldump command in linux platform to take backup of the database,its work properly....the command am used is
mysqldump -u root -p threadpool > sampledatabase.sql
I need to execute the same command in java....?Anyone here to know how to do that....?Thanks in advance........Crosspost:
http://forum.java.sun.com/thread.jspa?threadID=5185230&messageID=9721722#9721722
http://forum.java.sun.com/thread.jspa?threadID=5185199&messageID=9721587#9721587
Do not mess the forum. -
Execute shell command from Java
Hi all,
I need some idea for executing shell script from Java programe.
For example i have start.sh script in /tmp/start.sh folder of unix server.
I want to execute shell script from local java code.
Any idea on this.Hi,
Read the following articles/posts, maybe this could help you:
How to execute shell command from Java
Running system commands in Java applications | java exec example | alvinalexander.com
Want to invoke a linux shell command from Java - Stack Overflow
Maybe you are looking for
-
I think the BT Wholesale Checker is incorrect, who...
I have had engineers from CASS outside my property throughout 2012, blowing fibre from a nearby village, wiring up FTTP to the telegraph pole outside my drive and doing final testing. I became quite friendly with these engineers and they kept me upd
-
when I use oracle 11 and have it set in automatic (in services) it operates properly. (after restart) When I have it in manual (in services) i get the message 'Firefox can't establish a connection to the server at localhost:1158.' We use the computer
-
PA40 doesn't call bespoke feature ZPA01?
There is a bespoke feature ZPA01 which was created some years ago and which is now not working when using transaction PA40. I have tried debugging the program for this i.e. /1PAPA/FEAT100ZPA01, but this doesn't even stop at my breakpoint which means
-
ORA-01034: ORACLE not available ORA-27101: shared mem Linux-x86_64 Error 2
Hello, I was in the process of importing a table and my VM Rhel 6 Oracle machine hung. I rebooted the machine and Im getting the following issues. SQL*Plus: Release 11.2.0.1.0 Production on Wed May 9 12:51:47 2012 Copyright (c) 1982, 2009, Oracle. Al
-
Best print-to-pdf settings for news articles
Hello, can anyone recommend appropriate settings to use for print to pdf of newspaper articles from a web browser? I archive articles from news sites as pdfs, which I then later use for both reading on pcs and portable devices and as print-outs. Spec