• Post Reply Bookmark Topic Watch Topic
  • New Topic

Any way to find location of "javac.exe" in the system using java program  RSS feed

 
krishna balaji
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
usually javc.exe is located in c:\jdk1.3\bin.is there any way to find location of bin folder are "javac.exe" file using java code.

What i actually want is i need a java program that tell me the location of "javac.exe" file
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try accessing the property associated with java.compiler. Look at the System class.
 
Sandeep Kumar S Jakkaraju
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
write a small program ..which recursively searches your drive .. and finds the location of javac.exe. you can use filters ..
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the File class. You can create a File object from a String that is a path to a directory. Then using the methods list() and listFiles() you can get the Files in that directory. Using filters in conjunction with those methods, you can look for Files with a specific extension or name. Then you can use getAbsolutePath() on a File to get the path returned as a String.

My beginning Java book discusses File objects in the chapter on stream output.
[ October 19, 2006: Message edited by: sven studde ]
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If defined you could read the value of the JDK_HOME environment variable. If the JRE that you are using to run the program also contains the JDK then you could use java.home or sun.boot.library.path properties. Or you could ask the user for the location of the JDK using a JFileChooser or, as other suggested, you can search your whole file system, but that might take a while.

Why do you need to know the location of the javac.exe
[ October 19, 2006: Message edited by: Edwin Dalorzo ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!