• Post Reply Bookmark Topic Watch Topic
  • New Topic

utility for compiling java files with options.  RSS feed

 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi rancher,

i want to create a utility application in java which can compile a java source file with options like -d , -classpath,-help etc.

there is a java.lang.Compiler class which can be used to compile a source file but how can i supply compile time options?

 
Paul Clapham
Sheriff
Posts: 22712
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to have made certain assumptions about that class. Why don't you check out its API documentation (follow the link in your post) and clarify things?
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use Runtime class under java.lang package for this.
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You seem to have made certain assumptions about that class. Why don't you check out its API documentation (follow the link in your post) and clarify things?


what assumption ? All i said is that java.lang.Compiler can be used to compile a java source file.

Ashwin Sridhar wrote:You could use Runtime class under java.lang package for this.

i would be helpful if you be more specific
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Process pr = Runtime.getRuntime().exec("javac test.java");

The Exec takes a String parameter and you could specify your compiler commands there
 
Winston Gutkowski
Bartender
Posts: 10574
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naveen yadav wrote:what assumption ? All i said is that java.lang.Compiler can be used to compile a java source file.

Can it? Have you actually read the documentation? Don't get shirty until you have.

Winston
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!