You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by triona28 <vi...@gmail.com> on 2007/07/31 10:12:52 UTC

new ant user - trying to run java cmd

Hi,
   I'm trying to run a class from built jar using ant but my script doesn't
pick up even my echos around it - what am I doing wrong?
this is the bit that's already in my script & works:
<target name="jar" depends="compile, expandjars" description="generate JAR
file" >
    <exec executable="${AppPath}/host/vergen.exe"
          outputproperty="AppVersion"
          resolveExecutable="true">
      <arg value="${AppPath}/src/version.cpp"/>
      <arg value="-report"/>
    </exec>

    <property name="jar.name"
value="${build}/HostSimulators_${AppVersion}.jar" />
   	

    <jar destfile="${jar.name}">
      <fileset dir="${build}/classes" />
      <fileset dir="${build}/jar"/>

      <fileset dir="src">
         <include name="**/*.jpg"/>
         <include name="**/*.properties"/>
         <include name="**/*.gif"/>
         <include name="**/*.txt"/>
         <include name="**/*.ghost"/>
         <include name="**/*.dec"/>
         <include name="**/*.nan"/>
      </fileset>

      <manifest>
      	<echo>mainfest</echo>
         <attribute name="Main-Class" value="com/tech/simulators/Main"/>
      </manifest>
    </jar>
  </target>

now when I run my Main.java in Eclipse - I use the Run -> Run with program
parameters {-cfg /simulators/simulators.cfg}

how can I do this Run in Ant? I've tried:
<target name="run" depends="jar">
    <java classname="Main" classpath="${jar.name}" fork="true"/>
  </target>
but with no luck!!

please help,

tri
-- 
View this message in context: http://www.nabble.com/new-ant-user---trying-to-run-java-cmd-tf4191525.html#a11919932
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: new ant user - trying to run java cmd

Posted by Alec Fernandez <Al...@sas.com>.
You list a depends="jar" which tells ant to find a target named "jar"
and run it before it runs the target named "run"

I suspect that you do not have a target named "jar" defined.

The java task accepts nested arg elements.

Here's a working example:

            <java classname="com.foo.management.metadata.MetaMgrMain"
classpath="${launcher.jar.file}" fork="true"
dir="${config.lev.logs.configure.dir}" failonerror="false"
outputproperty="@{outputproperty}" resultproperty="@{resultproperty}">
               <jvmarg
value="-Dapp.launch.config=${metamgr.jar.picklist}" />
               <jvmarg
value="-Dapp.repository.path=${install.vjr.repository.path}" />
               <arg value="-method" />
               <arg value="createRepository" />
               <arg value="-host" />
               <arg value="@{host}" />
               <arg value="-port" />
               <arg value="@{port}" />
               <arg value="-user" />
               <arg value="@{user}" />
               <arg value="-password" />
               <arg value="@{password}" />
               <arg value="-reposName" />
               <arg value="@{reposname}" />
               <arg value="-reposPath" />
               <arg value="@{repospath}" />
               <arg value="-reposEngine" />
               <arg value="BASE" />
               <arg value="-reposType" />
               <arg value="@{repostype}" />
               <arg value="-reposAccess" />
               <arg value="Online" />
               <arg value="-reposIsCM" />
               <arg value="@{reposiscm}" />
               <arg value="@{reposDependencyList}" />
            </java>

-Alec
-----Original Message-----
From: triona28 [mailto:vinnie.timoney@gmail.com] 
Sent: Tuesday, July 31, 2007 5:01 AM
To: user@ant.apache.org
Subject: Re: new ant user - trying to run java cmd


Hi,
   I've tried the following:
after:  <property name="jar.name"
value="${build}/SIP_HostSimulators_${RunwayVersion}.jar" />

I write:
<target name="run" depends="jar" description="run the Main class"> 
    <java jar="${jar.name}" fork="true"/>
  </target> 

but this returns: 
BUILD FAILED
C:\myProjects\runway_core\guitools\sims\build.xml:153: Problem: failed
to create  task or type target
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken
place.

where's the correct place to insert it in the build file? how do I
manage the parameters "-cfg/simulators.cfg"?

Thanks,

Tri




triona28 wrote:
> 
> Hi,
>    I'm trying to run a class from built jar using ant but my script 
> doesn't pick up even my echos around it - what am I doing wrong?
> this is the bit that's already in my script & works:
> <target name="jar" depends="compile, expandjars" description="generate

> JAR file" >
>     <exec executable="${AppPath}/host/vergen.exe"
>           outputproperty="AppVersion"
>           resolveExecutable="true">
>       <arg value="${AppPath}/src/version.cpp"/>
>       <arg value="-report"/>
>     </exec>
> 
>     <property name="jar.name"
> value="${build}/HostSimulators_${AppVersion}.jar" />
>    	
> 
>     <jar destfile="${jar.name}">
>       <fileset dir="${build}/classes" />
>       <fileset dir="${build}/jar"/>
> 
>       <fileset dir="src">
>          <include name="**/*.jpg"/>
>          <include name="**/*.properties"/>
>          <include name="**/*.gif"/>
>          <include name="**/*.txt"/>
>          <include name="**/*.ghost"/>
>          <include name="**/*.dec"/>
>          <include name="**/*.nan"/>
>       </fileset>
> 
>       <manifest>
>       	<echo>mainfest</echo>
>          <attribute name="Main-Class"
value="com/tech/simulators/Main"/>
>       </manifest>
>     </jar>
>   </target>
> 
> now when I run my Main.java in Eclipse - I use the Run -> Run with 
> program parameters {-cfg /simulators/simulators.cfg}
> 
> how can I do this Run in Ant? I've tried:
> <target name="run" depends="jar">
>     <java classname="Main" classpath="${jar.name}" fork="true"/>
>   </target>
> but with no luck!!
> 
> please help,
> 
> tri
> 

--
View this message in context:
http://www.nabble.com/new-ant-user---trying-to-run-java-cmd-tf4191525.ht
ml#a11920538
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: new ant user - trying to run java cmd

Posted by triona28 <vi...@gmail.com>.
Hi,
   I've tried the following:
after:  <property name="jar.name"
value="${build}/SIP_HostSimulators_${RunwayVersion}.jar" />

I write:
<target name="run" depends="jar" description="run the Main class"> 
    <java jar="${jar.name}" fork="true"/> 
  </target> 

but this returns: 
BUILD FAILED
C:\myProjects\runway_core\guitools\sims\build.xml:153: Problem: failed to
create
 task or type target
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

where's the correct place to insert it in the build file? how do I manage
the parameters "-cfg/simulators.cfg"?

Thanks,

Tri




triona28 wrote:
> 
> Hi,
>    I'm trying to run a class from built jar using ant but my script
> doesn't pick up even my echos around it - what am I doing wrong?
> this is the bit that's already in my script & works:
> <target name="jar" depends="compile, expandjars" description="generate JAR
> file" >
>     <exec executable="${AppPath}/host/vergen.exe"
>           outputproperty="AppVersion"
>           resolveExecutable="true">
>       <arg value="${AppPath}/src/version.cpp"/>
>       <arg value="-report"/>
>     </exec>
> 
>     <property name="jar.name"
> value="${build}/HostSimulators_${AppVersion}.jar" />
>    	
> 
>     <jar destfile="${jar.name}">
>       <fileset dir="${build}/classes" />
>       <fileset dir="${build}/jar"/>
> 
>       <fileset dir="src">
>          <include name="**/*.jpg"/>
>          <include name="**/*.properties"/>
>          <include name="**/*.gif"/>
>          <include name="**/*.txt"/>
>          <include name="**/*.ghost"/>
>          <include name="**/*.dec"/>
>          <include name="**/*.nan"/>
>       </fileset>
> 
>       <manifest>
>       	<echo>mainfest</echo>
>          <attribute name="Main-Class" value="com/tech/simulators/Main"/>
>       </manifest>
>     </jar>
>   </target>
> 
> now when I run my Main.java in Eclipse - I use the Run -> Run with program
> parameters {-cfg /simulators/simulators.cfg}
> 
> how can I do this Run in Ant? I've tried:
> <target name="run" depends="jar">
>     <java classname="Main" classpath="${jar.name}" fork="true"/>
>   </target>
> but with no luck!!
> 
> please help,
> 
> tri
> 

-- 
View this message in context: http://www.nabble.com/new-ant-user---trying-to-run-java-cmd-tf4191525.html#a11920538
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: new ant user - trying to run java cmd

Posted by Pushkar Prasad <pu...@airtightnetworks.net>.
<target name="run" depends="jar">
    <java jar="PathtoJar/jarname.jar" fork="true"/>
  </target>

and yes.. add a manifest to jar (Main class where the main() is there )

-----Original Message-----
From: triona28 [mailto:vinnie.timoney@gmail.com] 
Sent: Tuesday, July 31, 2007 1:43 PM
To: user@ant.apache.org
Subject: new ant user - trying to run java cmd


Hi,
   I'm trying to run a class from built jar using ant but my script doesn't
pick up even my echos around it - what am I doing wrong?
this is the bit that's already in my script & works:
<target name="jar" depends="compile, expandjars" description="generate JAR
file" >
    <exec executable="${AppPath}/host/vergen.exe"
          outputproperty="AppVersion"
          resolveExecutable="true">
      <arg value="${AppPath}/src/version.cpp"/>
      <arg value="-report"/>
    </exec>

    <property name="jar.name"
value="${build}/HostSimulators_${AppVersion}.jar" />
   	

    <jar destfile="${jar.name}">
      <fileset dir="${build}/classes" />
      <fileset dir="${build}/jar"/>

      <fileset dir="src">
         <include name="**/*.jpg"/>
         <include name="**/*.properties"/>
         <include name="**/*.gif"/>
         <include name="**/*.txt"/>
         <include name="**/*.ghost"/>
         <include name="**/*.dec"/>
         <include name="**/*.nan"/>
      </fileset>

      <manifest>
      	<echo>mainfest</echo>
         <attribute name="Main-Class" value="com/tech/simulators/Main"/>
      </manifest>
    </jar>
  </target>

now when I run my Main.java in Eclipse - I use the Run -> Run with program
parameters {-cfg /simulators/simulators.cfg}

how can I do this Run in Ant? I've tried:
<target name="run" depends="jar">
    <java classname="Main" classpath="${jar.name}" fork="true"/>
  </target>
but with no luck!!

please help,

tri
-- 
View this message in context:
http://www.nabble.com/new-ant-user---trying-to-run-java-cmd-tf4191525.html#a
11919932
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org