• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compile a java program from another program  RSS feed

 
Gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to write a java program which compiles another java file in a predefined location and read the output stream to get the compilation messages.

Could someone help me with this.

Thanks
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Java bee,
You can use the RunTime.exec("..") to compile another java code. check this article

Then please change your display name before a bartender catches you.
[ June 17, 2005: Message edited by: Srinivasa Raghavan ]
 
Gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srini,

I tried to use Runtime().exec but it's not working

Thanks
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you are working in windows set the path correctly ( C:\jdk1.3\bin ) so that it can execute the java / javac option, if you are working in unix flaours set the path accordingly and try to run the program.
You said it's not working ?? Are you getting any compilation error or any runtime Exception or ?? be more specific so that people can answer correctly
Try this code...

[ June 17, 2005: Message edited by: Srinivasa Raghavan ]
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to use Runtime().exec but it's not working


How did you try it? Did you put it in your toaster? Call it with an int? A String? What do you mean it's not working? Does it give you an error message? Does your computer reboot? Order a pizza?

We don't ask for much here at the Ranch, but one thing we need from a person looking for help is -- You must be willing to help yourself. Tell us what you've tried; tell us the results. Then you'll get a good response
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!