RSS Forums RSS

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

Please support our Java advertiser: Programming Forums
Reply
Posts: 14
Reputation: w32.sysfile is an unknown quantity at this point 
Solved Threads: 0
w32.sysfile w32.sysfile is offline Offline
Newbie Poster

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

  #1  
Sep 5th, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Posts: 85
Reputation: hidash_in has a little shameless behaviour in the past 
Solved Threads: 0
hidash_in's Avatar
hidash_in hidash_in is offline Offline
Junior Poster in Training

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

  #2  
Oct 10th, 2007
can u tell where u r running ur program in command prompt or any other java compilation software.
reply as soon.
Reply With Quote  
Posts: 4,111
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 458
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is online now Online
Industrious Poster

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

  #3  
Oct 10th, 2007
If you are running in Windows, try prefacing the command with "cmd /c start ";
Reply With Quote  
Posts: 5,749
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Solved Threads: 205
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

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

  #4  
Oct 10th, 2007
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Posts: 74
Reputation: lookof2day is an unknown quantity at this point 
Solved Threads: 9
lookof2day lookof2day is offline Offline
Junior Poster in Training

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

  #5  
Oct 11th, 2007
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 2231 | Replies: 4 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:45 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC