943,685 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3111
  • Java RSS
Sep 5th, 2007
0

Runtime.getruntime.exec(); for my java compiler

Expand Post »
i face a problem here..

i am creating a compiler for java, the compilation part is done,and now i have a problem in the running the class compiled..

i use the runtime.getruntime().exec() method to run the class..

and what happen is, for example, i have a simple java file like

public static void main(String[]args)
{
System.out.print("This message");
}
and i run this class

it will show a line in the command prompt "this message",but after that it will closed straigth away, thus, the user has no chance to see the output of the class..

can anyone help me, sorry for my bad english
hope that you all understand
thanks
Similar Threads
Reputation Points: 9
Solved Threads: 0
Newbie Poster
w32.sysfile is offline Offline
14 posts
since Aug 2007
Oct 10th, 2007
0

Re: Runtime.getruntime.exec(); for my java compiler

can u tell where u r running ur program in command prompt or any other java compilation software.
reply as soon.
Reputation Points: 1
Solved Threads: 0
Junior Poster in Training
hidash_in is offline Offline
85 posts
since Oct 2007
Oct 10th, 2007
0

Re: Runtime.getruntime.exec(); for my java compiler

If you are running in Windows, try prefacing the command with "cmd /c start ";
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,757 posts
since May 2007
Oct 10th, 2007
0

Re: Runtime.getruntime.exec(); for my java compiler

you are not creating a compiler, you're creating a program that tries to call a compiler someone else created.

The reason your output is not retained is likely because you're launching another process which under Windows means another command shell, which gets closed as soon as that process completes.

And all that when you don't have to create another process at all, but can run any public method in any Java class from any method in any other Java class as long as the class you want to access is on the classpath.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Oct 11th, 2007
0

Re: Runtime.getruntime.exec(); for my java compiler

Well in that case I simply add a readline statement after the print statement. So unless and until you don't press a key it won't exit.
Reputation Points: 16
Solved Threads: 11
Junior Poster in Training
lookof2day is offline Offline
83 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: refining a programme
Next Thread in Java Forum Timeline: Need some tips..





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC