Solved

start another program from an application

Posted on 2006-11-03
6
216 Views
Last Modified: 2010-03-31
Hi Experts,


A simple question...

I have developed an application and from that application I have to start another application that is on my hard disk.
Is there a way to start that outside application from my application.



Thanks
0
Comment
Question by:blarouche
  • 3
  • 2
6 Comments
 
LVL 5

Assisted Solution

by:gkishoreji
gkishoreji earned 50 total points
ID: 17868632
u can use Runtime.exec to execute that application
0
 

Author Comment

by:blarouche
ID: 17868767
The file I have to start is in my F:\ua\EzDownloader.exe

How would I code that?


0
 
LVL 14

Accepted Solution

by:
hoomanv earned 75 total points
ID: 17868811
Runtime.getRuntime().exec("F:/ua/EzDownloader.exe");
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:blarouche
ID: 17868900

I get the following messasge when I run the code :

java.lang.IllegalThreadStateException: process has not exited
      at java.lang.ProcessImpl.exitValue(Native Method)
      at alarms.Test.main(Test.java:13)


I have to say that when I  excecute EzDownloader,  another message box appears and ask me to push on the button Download now.
0
 

Author Comment

by:blarouche
ID: 17868910
I forgot to include my code :

import java.util.*;
import java.io.*;


public class Test
{
    public static void main(String args[])
    {
        try
        {            
            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec("F:/ua/EzDownloader");
            int exitVal = proc.exitValue();
            System.out.println("Process exitValue: " + exitVal);
        } catch (Throwable t)
          {
            t.printStackTrace();
          }
    }
}
0
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 75 total points
ID: 17868939
exitValue() throws IllegalThreadStateException - if the subprocess represented by this Process object has not yet terminated.

You can use waitFor to wait for the process to terminate
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Eclipse Neon and jdk 1.8.0 11 126
JavaScript/Java - Changing an image background color 4 54
Java SE 8u111  Lot of stuff broke 11 53
varialbe initialization 11 30
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now