Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting properties in external file

Status
Not open for further replies.

DoraC

Programmer
May 7, 2002
98
US
Hi,

I am trying to run a java class in a step in my Ant script,
and it does NOT work when I set the variable in an external parm file but it DOES work when I set the variable internally.

For example, the following works:
Code:
  <property name=&quot;javac.path&quot; 
   value=&quot;/projects/install/Antlr/antlr-2.7.2/antlr.jar&quot;/>

...  
  <target name=&quot;processGrammarFile&quot; 
          depends=&quot;&quot;
          description=&quot;&quot;>

    <echo message=&quot;path: .${javac.path}.&quot;/>

    <java classname=&quot;antlr.Tool&quot;
               fork=&quot;true&quot;>
      <arg value=&quot;t.g&quot;/>
      <classpath path=&quot;${javac.path}&quot;/>
    </java>

  </target>

but the following does not:
Code:
(in common.properties file):
javac.path=&quot;/projects/install/Antlr/antlr-2.7.2/antlr.jar&quot;

(in build.xml)
  <property name=&quot;antlr.home&quot;
           value=&quot;C:/antlr/home/here&quot;/>
  <property file=&quot;${antlr.home}/common.properties&quot;/>

...  
  <target name=&quot;processGrammarFile&quot; 
          depends=&quot;&quot;
          description=&quot;&quot;>

    <echo message=&quot;path: .${javac.path}.&quot;/>

    <java classname=&quot;antlr.Tool&quot;
               fork=&quot;true&quot;>
      <arg value=&quot;t.g&quot;/>
      <classpath path=&quot;${javac.path}&quot;/>
    </java>

  </target>

It generates the following:
Code:
processGrammarFile:
     [echo] path: .&quot;/projects/install/Antlr/antlr-2.7.2/antlr.jar&quot;.   build.xml:processGrammarFile
     [java] java.lang.NoClassDefFoundError: antlr/Tool
     [java] Exception in thread &quot;main&quot; 
     [java] Java Result: 1
     [echo]     done!!!

Why won't it recognize a variable that's been set in a properties file, even when the values thus set are displayed properly in the echo statement? Admittedly, this is the first time I've tried this with the <java> task vs. <javac>, but I would imagine it should work for both...

any help would be thrilling...
thanks!
dora c
 
Hi,

OK, I found that it works if I remove the quotes from the
assignment in my common.properties file, so
Code:
javac.path=&quot;/projects/install/Antlr/antlr-2.7.2/antlr.jar&quot;

goes to
Code:
javac.path=/projects/install/Antlr/antlr-2.7.2/antlr.jar

and all is well. This is still strange, however, as I copied that verbatim from other common.properties files i've used w/success... but - again - not for the <java> task, just <javac>.

Thanks,
dora c
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top