aspose file tools*
The moose likes Java in General and the fly likes Running a java program from within another one Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running a java program from within another one" Watch "Running a java program from within another one" New topic
Author

Running a java program from within another one

geetha r
Greenhorn

Joined: Aug 09, 2007
Posts: 3
Hi..

Could somebody please tell me how to run a java program from another one when they are in separate packages? The issue is that the java package from which I am trying to access it is not the same as the class file I need to access.

This is the code I am using now :

try{
Runtime runtime = Runtime.getRuntime();
File destDir = new File("/Users/abc/minion/trunk/translator/bin");

String[] args1 =
new String[]{"sh","-c",
"java EssencePrimeTranslator",
"/Users/abc/trans/problems/sokoban/modeltest.cm",
"/Users/abc/trans/problems/sokoban/modeltest.param",
"/Users/abc/trans/problems/sokoban/modeltest.minion"};

runtime.exec(args1,null,destDir);
}
catch(Exception exp){
System.out.println("Exception in run : " + exp.toString());
}

Thanks in advance for the help!!!
sathish kumar
Ranch Hand

Joined: Feb 14, 2007
Posts: 47
Can you bundle everything into a ant script and run the ant script from java application.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...

(And "chemical agent" please check your private messages)


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
geetha r
Greenhorn

Joined: Aug 09, 2007
Posts: 3
Hi Satish,

Thanks for your response. I am not sure of how to go about doing it though, could you please elaborate?
geetha r
Greenhorn

Joined: Aug 09, 2007
Posts: 3
Thanks for your help with this...
The problem is solved. It can be done using the following :

Runtime runtime = Runtime.getRuntime();
String[] args1 = new String[]{
"java","-classpath",
"/Users/abc/minion/trunk/translator/bin","EssencePrimeTranslator",
"/Users/abc/trans/problems/sokoban/modeltest.cm",
"/Users/abc/trans/problems/sokoban/modeltest.param",
"/Users/abc/trans/problems/sokoban/modeltest.minion"};

runtime.exec(args1);
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

"geetha r"

Your name still does not conform to the JavaRanch Naming Policy. Please review the policy and update it appropriately. This is your second warning.

Scott Selikoff


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running a java program from within another one