You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ray Tayek <rt...@comcast.net> on 2005/11/06 03:10:25 UTC

how to get one class file into classpath in ant?

hi, using the following fragment from the ant build file (see below):

	<target name="runsanscp" depends="compile" description="runusingjar">
		<java classname="Main">
			<classpath>
				<dirset dir="${bin}/src">
					<include name="Main.class" />
				</dirset>
			</classpath>
		</java>
	</target>

log file says:

runsanscp:
      [java] Running in same VM Executing 'Main' with
dirset: Setup scanner in dir 
I:\ray\workspace\areallysimpleone\bin\src with patternSet{ includes: 
[Main.class] excludes: [] }
force loading Main
Finding class Main
      [java] Could not find Main. Make sure you have it in your classpath
      [java] 	at 
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:170)

trying <fileset> fails also.

anybody got a clue?

thanks

build.xml:

<project name="areallysimpleone" default="run" basedir=".">
	<description>sample ant build file</description>
	<property environment="env" />
	<property file="${user.home}/build.properties" />
	<property file="build.properties" />
	<property name="src" location="src" />
	<property name="tst" location="tst" />
	<property name="bin" location="bin" />
	<property name="dist" location="dist" />
	<property name="ant.home" value="${env.ANT_HOME}" />
	<echo message="env.ANT_HOME=${env.ANT_HOME}" />
	<echo message="env.JAVA_HOME=${env.JAVA_HOME}" />
	<echo message="rt.jar=${env.JAVA_HOME}/jre/lib/rt.jar" />
	<property name="junit.jar" value="${ant.home}/lib/junit.jar" />
	<!-- usually one hangs out here -->
	<target name="init">
		<tstamp />
		<mkdir dir="${bin}" />
		<mkdir dir="${bin}/src" />
		<mkdir dir="${bin}/tst" />
		<mkdir dir="${dist}" />
	</target>
	<path id="lib">
		<fileset dir="lib" includes="*.jar" />
	</path>
	<target name="clean" description="clean">
		<delete dir="${bin}" />
		<delete dir="${dist}" />
	</target>
	<target name="compile" depends="init" description="compile">
		<javac srcdir="${src}" destdir="${bin}/src">
			<classpath>
				<path refid="lib" />
			</classpath>
		</javac>
	</target>
	<target name="run" depends="compile" description="run">
		<java classname="Main">
			<classpath>
				<path refid="lib" />
				<pathelement path="${bin}/src" />
			</classpath>
		</java>
	</target>
	<target name="runsanscp" depends="compile" description="runusingjar">
		<java classname="Main">
			<classpath>
				<!--fileset file="${bin}/src/Main.class"/-->
				<!--fileset dir="${bin}/src" includes="Main.class"/-->
				<!--filelist dir="${bin}/src" files="Main.class"/-->
				<dirset dir="${bin}/src">
					<include name="Main.class" />
				</dirset>
			</classpath>
		</java>
	</target>
</project>


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


Re: how to get one class file into classpath in ant?

Posted by Ray Tayek <rt...@comcast.net>.
At 06:47 AM 11/9/2005, you wrote:
> >        <target name="runsanscp" depends="compile" 
> description="runusingjar">
> >                <java classname="Main">
> >                        <classpath>
> >                                <dirset dir="${bin}/src">
> >                                        <include name="Main.class" />
> >                                </dirset>
> >                        </classpath>
> >                </java>
> >        </target>
> > anybody got a clue?
>
>I'm afraid you don't understand what a Java classpath is. Please do
>some reading on it. Just like you do list individual programs in a
>PATH, you don't list individual classes in a CLASSPATH. --DD

ok. but it seems like there should be some way to get just a few 
classes on a classpath without having to jar them up.

thanks 


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


Re: how to get one class file into classpath in ant?

Posted by Dominique Devienne <dd...@gmail.com>.
>        <target name="runsanscp" depends="compile" description="runusingjar">
>                <java classname="Main">
>                        <classpath>
>                                <dirset dir="${bin}/src">
>                                        <include name="Main.class" />
>                                </dirset>
>                        </classpath>
>                </java>
>        </target>
> anybody got a clue?

I'm afraid you don't understand what a Java classpath is. Please do
some reading on it. Just like you do list individual programs in a
PATH, you don't list individual classes in a CLASSPATH. --DD

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