Results 1 to 3 of 3

Thread: Runtime.exec()

  1. #1
    hknyo is offline Member
    Join Date
    Jun 2008
    Posts
    2
    Rep Power
    0

    Question Runtime.exec()

    Hi all,
    I am launching some external applications from java Runtime.exec(). It works fine when everything goes well(i.e the application path is correct, file to launch is ok. etc...) but I wonder is there any way to determine if the application is installed before I launch, since I believe Runtime.exec() does not provide much control after it is called. I just need to know how I can determine if the application exists(installed) before I launch from java . It doesn't have to be using java Runtime but any method would be fine. here is my general scenerio

    1. 1 of 2 applications to lunch
    2. I can assume that the user will have at least one of them installed
    3. depending on what is installed, I willl launch using it
    4. if both of them are installed, I will give the user to select one of them.


    Thanks in advance
    Nick

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    I assume that the applications are files located somewhere on the OS's path (the PATH environ var in windows, I don't know about other OS). If you can get the value of PATH, then you could look on all the paths for the file that starts the application.

  3. #3
    mrcheeks is offline Member
    Join Date
    Jan 2008
    Posts
    22
    Rep Power
    0

    Default

    You can use the file methods
    if(new File(myapplicationFullPath).exists()){
    Runtime.getRuntime().exec(myapplicationFullPath);
    }

Similar Threads

  1. Problem with Runtime.exec()
    By nhabibi in forum Advanced Java
    Replies: 11
    Last Post: 07-02-2008, 02:35 AM
  2. Runtime.exec(), handling input and output streams
    By crookshank in forum New To Java
    Replies: 0
    Last Post: 06-05-2008, 03:41 PM
  3. Exec cmd from Java application
    By javaplus in forum New To Java
    Replies: 0
    Last Post: 12-17-2007, 09:41 AM
  4. Nuxeo Runtime 1.2
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 06-22-2007, 07:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •