Solved

start another program from an application

Posted on 2006-11-03
6
212 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

757 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

16 Experts available now in Live!

Get 1:1 Help Now