axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Venkat Reddy <vred...@gmail.com>
Subject Re: [Axis2] problem with using the Ant Javac programmatically
Date Thu, 11 Aug 2005 14:06:31 GMT
I know. If the basic idea really works for you atleast on windows, it
gives the hint and you can always find an equivalent command for other
platforms :-)

- venkat

On 8/11/05, Eran Chinthaka <chinthaka@opensource.lk> wrote:
> Small problem. IMHO, this will work only in windows. You have used cmd.exe.
> 
> >
> > Ajith,
> >
> > I used the following code to get the value of environment variable
> > "JAVA_HOME" instead of sysetm variable "java.home" which always points
> > to jre.
> >
> >     public static String getEnv(String env) throws Exception { //
> > env="JAVA_HOME"
> >         Properties envVars = new Properties();
> >         Runtime r = Runtime.getRuntime();
> >         Process  p = r.exec( "cmd.exe /c set" );
> >         BufferedReader br = new BufferedReader ( new
> > InputStreamReader( p.getInputStream() ) );
> >
> >         for (String line; (line = br.readLine()) != null; ) {
> >             int idx = line.indexOf( '=' );
> >             String key = line.substring( 0, idx );
> >             if (key.equals(env))
> >                 return line.substring( idx+1 );
> >         }
> >         return "";
> >     }
> >
> > - venkat
> >
> >
> > On 8/9/05, Guillaume Sauthier <Guillaume.Sauthier@objectweb.org> wrote:
> > > 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
> > >
> > >
> > >
> 
> 
> 
>

Mime
View raw message