The Artima Developer Community
Sponsored Link

Java Answers Forum
How to run other Java program in a java application

1 reply on 1 page. Most recent reply: May 24, 2002 5:44 PM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
syf

Posts: 1
Nickname: freevictor
Registered: May, 2002

How to run other Java program in a java application Posted: May 24, 2002 9:03 AM
Reply to this message Reply
Advertisement
I wrote a program like this:


import BounceThread;//the java program I want to run
import java.lang.*;
public class Test {
public static void main(String[] args) {
String[] str={"",""};
BounceThread.main(str);
}
}


The program BounceThread runs.
But if BounceThread is not in the same path with Test ,how can I make it?
The problem is I can't "import" the class BounceThread.
Thank for reply!


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: How to run other Java program in a java application Posted: May 24, 2002 5:44 PM
Reply to this message Reply
I am not quiet sure to understand what you want to do. Here is one solution :
Here is a first file : UseMain.java
package test.lang;
 
public class UseMain
{
  public static void main (String[] args)
  {
    System.out.println ("UseMain - start");
    UseMain2.main (null);
    System.out.println ("UseMain - end");
  }
}
Here is the second file : UseMain2.java
package test.lang;
 
public class UseMain2
{
  public static void main (String[] args)
  {
    System.out.println ("UseMain2 - start");
  }
}
There is then the more common way of working : with (by heart) :
System.getRunTime().exec(new String[] {"javac", 
                                       "-cp opt/jdk/1.3/lib/rt.jar", 
                                       "MyClassFileFullyQualified", 
                                        "Argument_1 Argument_2 Argument_3"});

I thing it should be like that :-D
If you need opther option, please post on the forum !

Thomas SMETS,
SCJP2 - Brussels

P.S. :
http://www.artima.com/forums/howtopost.html

Flat View: This topic has 1 reply on 1 page
Topic: Difference between ArrayList and Vector Previous Topic   Next Topic Topic: require some help in java project please?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use