Hi Ajith

java.home sysprop is always pointing to the JRE directory.
In JOnAS, when we launch the javac command, we have to use this little code snippet to get a real java.home (a JDK home)

           javaHomeBin = System.getProperty("java.home", "");
           if (!("".equals(javaHomeBin))) {
               if (Env.isOsMacOsX()) {
javaHomeBin = javaHomeBin + File.separator + "bin" + File.separator;
               } else {
javaHomeBin = javaHomeBin + File.separator + ".." + File.separator + "bin" + File.separator;
               }
           }

Maybe you can use this and reassign the java.home sysprop ?

Bye
Guillaume

Ajith Ranabahu wrote:

Hi all,
I am writing an end to end test case for the code generator. To compile the generated code I use the Javac task from Ant. However I 've come across some problems, specially a weird problem where the 'java.home' appears to be pointing to the Java runtime instead of the JDK home.
Here are the details of the problem
I've used the Javac class (from Ant) to run the compiler. When I run the compiler I get an error message saying "Unable to find compiler, Perhaps the JAVA_HOME is pointing to the correct place". I've gone through the Javac code and then figured out that the compiler is searched using the 'java.home' directory. Strangely I have my JAVA_HOME pointed to c:\java\jdk1.4 but the 'java.home' system property points to the c:\java\jdk1.4\jre directory (where there is no reference to the tools.jar) and the compile task fails miserably :(. I did some tests and figured that the value of the java.home system property changes according to the environment you run java !
Currently the compile code is commented.
Any pointer is appreciated

Thanks
--
Ajith Ranabahu


Reply via email to