i want to execute ine java program from java. iam sending my code.please see this. is it correct.when i executing it is not displaying any public class prs { public static void main(String args[]) { try {
Runtime r=Runtime.getRuntime(); Process p=null; p=r.exec("java Hastable1");//here Hastable1 is another java program } catch(Exception e) { e.printStackTrace(); } } } if this is not correct please tell me how to do this
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
Why not include Hastable1 in your classpath and call it from your program like this:
I Haven't understand these parameters and i don't need any parametersand my requirement is to execute some other java class from java program.please see where the problem is.if possible please modify my program and sent it to me as it is urgent for me
Ulf was saying that there is nothing special about a 'ajav program', it is a Java class that gets run using its 'main' method. You can call the 'main' method from your class and it will cause the other 'class' to be run just like it is run from the command line (more or less).
If you have other requirements please be more specific on the problem you are having.
pvsr rao
Ranch Hand
Joined: Oct 05, 2005
Posts: 102
posted
0
i don't need any streams and i have used parameters also.but it is giving errors. from java program i need to execute some other java class please send any code regarding this to me
pvsr rao
Ranch Hand
Joined: Oct 05, 2005
Posts: 102
posted
0
my actual requirement is from the java program i have to start the weblogic server by interactively giving the domainname,servername etc.
i have executed like normal java class only.it is not giving any errors or output.just blankscreen is comming
Norm Radder
Ranch Hand
Joined: Aug 10, 2005
Posts: 681
posted
0
What happens if you execute a program that has this statement:
Hastable1.main(new String[]{}); // call main() method of Hastable1
Copy and paste here the commandline and all of the console messages.
pvsr rao
Ranch Hand
Joined: Oct 05, 2005
Posts: 102
posted
0
it is giving the error as cannot resolve symbol Hastable1.can we import that Hastableclass
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
I suggested earlier to include Hastable1 in your classpath. Without that, it will not work. And yes, you will need to add an import statement, but without the class being in the classpath that won't do much good.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.