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 advance

Example 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

Similar Messages

  • Enable to  run .exe file which is created from .air file  in windows 7?

    Enable to  open .exe file which is created from .air file which is created from adt command in windows 7 .
    for run .exe file ::
    The user must right click and select "Run as Administrator" for run successfully.
    so How to remove this above permission issue in Windows 7?
    Thanks
    Sunil

    Right-click on the exe file and choose Properties.
    Switch to the compatibility tab and uncheck the box next to "Run this program as an administrator". Click "ok".

  • Can't run Pshop and another adobe program at the same time

    Hi all,
    I'm experiencing a frustration problem. I can't run two adobe programs a the same time - ie, Lightroom and photoshop, After effects and photoshop.
    Lightrrom and After effects sem to be playing together okay at the moment so looks like it may be a PShop issue.
    Running final release of windows 7 64 bit, licenced PS3, trial AE, trial PS4....8GB Ram,  has been with both Nvidia and ATI video cards, open GL on , Open GL off, seperate scratch disks, reinstalled everything,
    Any help, advice, hints would be really appreciated as having to close programs all the time when switching apps is a real pain in the neck
    cheers
    Jeff

    thanks whytefly,
    yeah I thought that may be the case but then realised both After effects and CS3 are 32bit (86x) and I can't run those together
    I'm jealous as hell that you can run 3 together  haha,
    cheers
    Jeff

  • Problems running external Win32 Multithread C-Program from Java

    hi,
    i just wrote a little java application which is calling my c-binary (a win32 multithread application written in pure ansi c) . let's call it "test.exe". i'm launching it via:
    Runtime.getRuntime().exec(cmd, new String[] { env }, dir)the program is started correctly and i get all test.exe outputs on my java console (therefor i grabbed the inputstream and errorstream of the process-object ...). so far so good.
    my problem is, that something with the multithreading seems to be wrong, when launching my test.exe from java!
    for example, i have the following line of code in my c-program (test.exe):
    WaitForSingleObject( g_hMutexREADY, INFINITE );if i launch my program as java process, this line seems to be ignored! that means, the program doesn't stop executing at this point (and is waiting for the mutex) but simply continues executing, causing the whole program to crash.
    if i run the same program directly from the winxp commandline all is working fine (that means: the threads of 'test.exe' synchronize each other correctly via the mutexes)!
    does anybody has an idea or have already had similar problems? maybe some win32 libraries are missing, could that be?
    thanks a lot.
    k4simir

    I just debugged a little bit through my c program. and it's not the multithrading stuff causing the error, but the win32 socket creation!
    my "multithreading c program" :-) is an ASR (automatic speech recognizer). it runs as socket server (on localhost) and accepts connections from clients (my java application). the client (java app) controls the ASR server (means start(), stop(), open(), close() ...). if the ASR server recognizes some user input, it will transfer it to the client for further processing.
    so far the theory. if i launch the ASR server via the window command line, the communication and the other stuff works fine. now i want my java app to launch the ASR server.
    the ASR fails, when it tries to create the socket:
    g_Vars.kServSock = socket( AF_INET, SOCK_STREAM, 0 );the error code returned by WSAGetLastError() is 10106! i didn't find this error code in the msdn! so i don't know what it means or what might be the problem.
    any ideas?
    thanks a lot!
    k4simir
    here's the full code:
    int     InitSocket( short sPortNr ) {
         int               iErr;
         SOCKADDR_IN     kMyAddr;
         iErr = StartUp();
         if( iErr != _SRC_OK ) {
              return _SRC_ERROR;
         // create server-socket:
         g_Vars.kServSock = socket( AF_INET, SOCK_STREAM, 0 );
         if( g_Vars.kServSock == INVALID_SOCKET ) {
              CleanUp();
              return _SRC_ERROR;
    int StartUp() {
         WORD wVersionRequested;
         WSADATA wsaData;
         int err;
         _DEBUGPRINT
         wVersionRequested = MAKEWORD( 2, 2 );
         err = WSAStartup( wVersionRequested, &wsaData );
         if ( err != 0 ) {
              return _SRC_ERROR;
         if ( LOBYTE( wsaData.wVersion ) != 2 ||
               HIBYTE( wsaData.wVersion ) != 2 ) {
              WSACleanup( );
              return _SRC_ERROR;
         return _SRC_OK;
    }

  • How can I open help file (HTML or .chm) from Java Web Start (new to JAVA)

    Hi All,
    Im trying to open the help file of my application.
    When trying to access the help file from the GUI (pressing F1 for launching the help file), I'm geting the an error, something like:
    "Can't show help URL: jar:file:C:\Documents and Settings\%USER%\Application Data\Sun\Java\Deployment\javaws\cache\http\Dlocalhost\P7001\DMwebstart\RMjar-name!/com/resources/helpFiles/MyHelpFile.html"
    It seems that the file which is packed in a jar, was downloaded to the Java Web Start cache directory:
    C:\Documents and Settings\%USER%\Application Data\Sun\Java\Deployment\javaws\cache\http\Dlocalhost\P7001\DMwebstart
    The code which is activated when launching the help file is:
    try
                ResourceBundle resourceBundle = DoubleResourceBundle.getBundle("Resource", "ResourceImpl");
                RuntimeUtil.launchFile(new File(resourceBundle.getString("help.file")));
            } catch (IOException e)
                // TODO Auto-generated catch block
                e.printStackTrace();
            }where the property "help.file" is in some property file in the resource bundle named "Resource", and looks like this :
    help.file="com/trax/docs/help/global/MyHelpFile.html"
    The function "RuntimeUtil.launchFile" knows how to launch any file in its default application, and indeed it does launches the html, when giving it an absolute path to the file on my PC, as "C:\Helpfiles\MyHelpFile.html" as such:
    RuntimeUtil.launchFile("C:\Helpfiles\MyHelpFile.html");My question is :
    The application is going to be deployed on a Customer PC. How can I access the html file from the code, with a relative path and not its absolute path on the customer pc, which I can't know?
    I found these restrictions regarding web start:
    (copied from "http://rachel.sourceforge.net/"):
    *Rule 1: Java Archives only. No loose files.* All your resources have to be packaged in Java Archives (jar) if you want to have
    them delivered to the user's machine and kept up-to-date automatically by Java Web Start.
    *Rule 2: No file paths.* You can't use absolute or relative file paths to locate your
    jars holding your resources (e.g. <code>jar:file:///c:/java/jws/.cache/resources.jar</code>).
    Absolute file paths won't work because you never know where Java Web Start
    will put your jar on the user's machine. Relative file paths won't work because Java Web Start
    mangles the names of your jars (e.g. <code>venus.jar</code> becomes <code>RMvenus.jar</code>)
    and every JNLP client implementation has the right to mangle your names
    in a different way and you, therefore, can't predict the name with
    which your jar will be rechristend and end up on the user's machine in
    the application cache.Seems complex or impossible, to perform a simple task like opening a file.
    Please advise (I'm new to Java and Web Start).
    BTW, I'm working with IntelliJ IDEA 5.0.
    Thanks,
    Zedik.
    {font:Tahoma}{size:26pt}
    {size}{font}

    the follwing method i have used to open html file ...
    so to access html file i am shipping resources folder with jar file ..
    private void openHtmlPages(String pageName) {
         String cmd[] = new String[2];
         String browser = null;
         File file = null;
         if(System.getProperty("os.name").indexOf("Linux")>-1) {
              file = new File("/usr/bin/mozilla");
              if(!file.exists() ) {
              }else     {
                   browser = "mozilla";
         }else {
              browser = "<path of iexplore>";
         cmd[0] = browser;
         File files = new File("");
         String metaData = "/resources/Help/Files/"+pageName+".html"; // folder inside jar file
         java.net.URL url = this.getClass().getResource(metaData);
         String fileName = url.getFile();
         fileName = fileName.replaceAll("file:/","");
         fileName = fileName.replaceAll("%2520"," ");
         fileName = fileName.replaceAll("%20"," ");
         fileName = fileName.replaceAll("jarfilename.jar!"," ").trim();
         cmd[1] = fileName;     
         try{
              Process p = Runtime.getRuntime().exec(cmd);
         }catch(java.io.IOException io){
                   //Ignore
    can anyone give me the solution..???
    Regards
    Ganesan S

  • Itunessetup.exe not a valid Win32 application - can't run exe file -

    I have the same pb.
    Can anybody help ?
    thks

    Hope that you find a resolution to the problem during the visit to the Apple store. However if not, I would suggest you should reconsider buying a new PC. As this seems to be a common problem it suggests there is a problem with the iTunes software itself, not your PC.
    Although it's not an ideal you could try reinstalling your operating system, however personally I think I'm going to wait a while and see if Apple come up with a solution to the problem.
    Good luck.
    Sony Vaio   Windows XP Pro  

  • Run exe file while i'm using the program

    hi there how can i run exe file while i'm using the program

    Hi,
    Hopefully HOST() command will do it. For more info about HOST() command look for documentation. Hopefully it will work fine.

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

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

  • How to run java programs from a master java program?

    Hello,
    I have several java programs which run from the command prompt. I am seeking help with code for starting java programs from within a java program. For example, a program called master.java works something like this:
    import java.*;
    create connection pool
    create variables and result sets
    start/run slave1.java (var1, var2);
    start/run slave2.java (var3, var4, var5);
    start/run slave3.java (var1, var4);
    end of program master.java
    Each of the slave.java programs will run for up to an hour. I do not want the master.java program to pause for each slave program to stop. Instead, the master program will keep running and multiple slave programs will be running simultaneously with the master program. When a slave program starts, it is on its own. Also, if possible, I would like to have each of these slave.java programs open in a new separate command window, so I can observe each slave program running in separate windows.
    Any suggestions for code or helpful documentation are greatly appreciated.
    Thank you,
    Logan

    Thank you all.
    At the bottom of master.java I have successfully started a batch file with these lines:
    String jcmd = "cmd.exe /c start c:/data/simulations/MsgViewCount2.bat";
    Process proc = Runtime.getRuntime().exec(jcmd);
    But I still cannot get a java program to start. Here is one variation I have tried:
    String [] cmdArray = new String[2];
    cmdArray[0] = "java";
    cmdArray[1] = "slave1";
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(cmdArray);
    This compiles, and no errors occur, but nothing happens.
    Regarding this comment:
    Why Runtime.exec? Either make the slaves Runnable or
    just call their main() methods.
    Oh, I see. Sepearate output. :PNone of the slave.java programs have any output.
    Thanks again.

  • Running a program from Java

    how do i launch one Java program from another?
    both .class files and the JRE directory are in the same directory

    You can use Runtime.exec() to run it as a seperate process, or you can always instantiate your secondary class. Do a search on the term "runtime.exec()" befure you go spawning another thread asking how to use it. That particular subject has been done to death many times already.

  • URGENT: How to run a Java program from a different directory?

    Hi.
    How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
    What would be the command to run the Java file from c:\Java.
    I can't remember it and I need it asap.
    Cheers.

    If the class you are trying to run is MyApp.class, try
    c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
    Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
    The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)".

  • Not able to execute one Java program from another one via. exec()

    Hi,
    I am new to this forum, so I might be asking a very trivial quetion.
    My program Ap1 is :
    class Ap1
    public static void main(String a[]) throws Exception
    Runtime rt=Runtime.getRuntime();
    Process p=null;
    p=rt.exec("javac,Pr.java");
    Runtime.getRuntime().exec("javac,Pr.java");
    When I run the above program, I get below error at the line 7(bold one):
    D:\batchwe>javac Ap1.java
    D:\batchwe>java Ap1
    Exception in thread "main" java.io.IOException: CreateProcess: javac,Pr.java err
    or=2
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
    at java.lang.Runtime.exec(Runtime.java:591)
    at java.lang.Runtime.exec(Runtime.java:429)
    at java.lang.Runtime.exec(Runtime.java:326)
    at Ap1.main(Ap1.java:7)
    Path is set as below(which seems correct):
    D:\batchwe>path
    PATH=C:\Program Files\Java\jdk1.5.0_05\bin
    I am just wondering how to call one Java program from another one?!
    Please help.
    thanks
    Rashmi

    Hi diptaPB,
    Thanks for your suggestion.
    Here is how I tried it again, but not getting the desired output:
    Class Pr looks like below -->
    class Pr
    public static void main(String a[])
    System.out.println("hi from process");
    When I run 'Pr' from command prompt, i get the desired output:
    D:\batchwe>java Pr
    hi from process
    However, when I call 'Pr' from another program Ap2.java, it seems that it does not call 'Pr':
    class Ap2
    public static void main(String a[]) throws Exception
    Runtime rt=Runtime.getRuntime();
    Process p=null;
    String[] cmd=new String[2];
    cmd[0]="javac";
    cmd[1]="Pr.java";
    p=rt.exec("cmd");
    D:\batchwe>javac Ap2.java
    D:\batchwe>java Ap2
    ************* no output appears here***********************
    Looking forward for your help.
    regards
    Rashmi

  • Execute a java program from an another program

    Like we can compile a code from wihin a java file by using the following :
    Tool javac = ToolProvider.getSystemJavaCompiler();
    Similarly,can we execute i.e. run a java program from within a java file i.e. running d java command from within the java file ??If yes then please tell me how??

    suppose on the Unix box or from a Unix script ( korn, perl, bourne, bash) you can run the following java program
    java ${JAVA_OPTS} -jar ${GMR_APPS_DIR}/risk.jar -I -c ${COB} -r ${BATCH} -o ${XML_DIR}
    in java you can do the following :
    Runtime rt = Runtime.getRuntime();
              try {
                   Process process = rt.exec("java ${JAVA_OPTS} -jar ${GMR_APPS_DIR}/risk.jar -I -c ${COB} -r ${BATCH} -o ${XML_DIR}
    // OR
                   Process process = rt.exec("/export/apps/Tools/apache-tomcat-5.5.17/bin/startup.sh");
                   // process.destroy(); if you want to kill the process
                   process.waitFor();
                   int RC = process.exitValue();      
                   System.out.println(returnOutput(process.getErrorStream()));
                   System.out.println(returnOutput(process.getInputStream()));
              } catch (Exception ex) {
                   ex.printStackTrace();
    empty the output stream from the script
    private String returnOutput(InputStream is) throws Exception {
                   String s;
                   StringBuffer strBuff = new StringBuffer();
                   BufferedReader br = new BufferedReader(new InputStreamReader(is));
                   while ((s = br.readLine()) != null) {
                        strBuff.append(s);
                   return strBuff.toString();
              }You need to relace the ${} by the appropriate values.
    Regards,
    Alan Mehio
    London, UK
    Edited by: alan_mehio on Jan 16, 2008 4:21 PM

  • How to run .exe files with Virtual PC for Mac

    Hey Guys, I'm new around here and with mac technology as well. Anyway, I have an iMac OS X 10.5.1 Leopard and I've recently purchased the Virtual PC for Mac 7.0.2 software. So I'd like to know how to use this program properly, because I need to run some executable files in my computer. It is confusing for me because I don't know how to get started, and I only get to the part when it says "OS not found, Install an OS on this hard drive".
    Honestly I've no idea of what an OS is or where do I get that. So I'd really appreciate if one of you guys could tell me, step by step, what to do to use Virtual PC properly, and finally learn how to run .exe files on mac.
    Thanks in advance!
    Have a nice day!

    Always nice to see new faces
    Honestly I've no idea of what an OS is or where do I get that.
    This brings up the second part of your problem. The first part is setting up either a proper Virtual Machine program like Parallels or VMfusion, or setting up a Boot Camp partition on your drive.
    http://www.parallels.com/
    http://www.vmware.com/products/fusion/
    OS stands for Operating System. You are running Leopard 10.5.7 as an operating system on your Mac (MacOS X).
    The second part of your problem - You will need a copy of Windows XP or Vista if you want to run Windows on your Mac.
    There is at least one other solution for running Windows programs on a Mac. It's called "CrossOver" by a company named 'Codeweavers'. It's based on a project for "Wine" to be able to run PC programs on a Mac or Linux, without having to buy or install Windows. It works with a narrow subset of Windows programs so you would want to make sure the program you want to run is compatible with CrossOver before you buy it.
    http://www.codeweavers.com/products/cxmac/
    In addition to all the above information, you need to upgrade your Mac to the latest 10.5.7 from 10.5.1. "Software Update" is located under the black Apple icon in the Menu Bar at the top left corner of your monitor. After you are updated you will want to update your Profile here so that it shows the proper OS version.
    With your level of experience with MacOS X and the Windows OS's you should probably get some help from a local Apple store. They have an appointment system and do offer many types of help and training, and they can offer assistance with choosing the proper programs for you to purchase for your machine.
    You are also welcome to continue to ask questions here, of course. You will want to ask your questions with different issues that come up in different threads so that the answers stay focused on the title of the thread.
    Message was edited by: dechamp to try to be more accurate with a fairly complicated issue...

Maybe you are looking for