I know such questions have been posted a lot, but I read the answers to some and still got the same problem:
I can`t produce a simple jar-File:
Typing ant jar results in:
Buildfile: build.xml
init:
compile:
jar:
[jar] Warning: skipping jar archive AntHelloWorld\jar\HelloWorld.jar because no files were included.
BUILD SUCCESSFUL
Total time: 0 seconds
Typing java -jar jar/HelloWorld.jar results in:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
In the HelloWorld.jar is only the Manifst.MF included, this looks like:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.6.0-b105 (Sun Microsystems Inc.)
Main-Class: HelloWorld
The HelloWorld.java is directly in the folder java.
The build.xml looks like:
<!-- name of your project, default target and starting point for all actions -->
<project name="AntHelloWorld" default="jar" basedir=".">
<description>Test
</description>
<!-- setting global properties -->
<property name="java" location="java"/>
<property name="class" location="class"/>
<property name="jar" location="jar"/>
<!-- building temporary (= redundant!) directories -->
<target name="init">
<tstamp>
<format property="TODAY_UK" pattern="MM-dd-yyyy" locale="en"/>
</tstamp>
<mkdir dir="$(class)"/>
<mkdir dir="$(jar)"/>
</target>
<!-- generating .class files -->
<target name="compile" depends="init">
<javac srcdir="${java}" destdir="${class}">
</javac>
</target>
<!-- generating executable jar file -->
<target name="jar" depends="compile">
<jar jarfile="${jar}/HelloWorld.jar"
basedir="$(class)"
includes="**/*.class">
<manifest>
<attribute name="Main-Class" value="HelloWorld"/>
</manifest>
</jar>
</target>
<!-- running the programm -->
<target name="run" depends="jar">
<java jar="${jar}/HelloWorld.jar" fork="true">
</java>
</target>
<!-- deleting temporary (= redundant!) directories and content -->
<target name="clean">
<delete dir="${class}"/>
<delete dir="${jar}"/>
</target>
</project>
Can somebody help me?
I can`t produce a simple jar-File:
Typing ant jar results in:
Buildfile: build.xml
init:
compile:
jar:
[jar] Warning: skipping jar archive AntHelloWorld\jar\HelloWorld.jar because no files were included.
BUILD SUCCESSFUL
Total time: 0 seconds
Typing java -jar jar/HelloWorld.jar results in:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
In the HelloWorld.jar is only the Manifst.MF included, this looks like:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.6.0-b105 (Sun Microsystems Inc.)
Main-Class: HelloWorld
The HelloWorld.java is directly in the folder java.
The build.xml looks like:
<!-- name of your project, default target and starting point for all actions -->
<project name="AntHelloWorld" default="jar" basedir=".">
<description>Test
</description>
<!-- setting global properties -->
<property name="java" location="java"/>
<property name="class" location="class"/>
<property name="jar" location="jar"/>
<!-- building temporary (= redundant!) directories -->
<target name="init">
<tstamp>
<format property="TODAY_UK" pattern="MM-dd-yyyy" locale="en"/>
</tstamp>
<mkdir dir="$(class)"/>
<mkdir dir="$(jar)"/>
</target>
<!-- generating .class files -->
<target name="compile" depends="init">
<javac srcdir="${java}" destdir="${class}">
</javac>
</target>
<!-- generating executable jar file -->
<target name="jar" depends="compile">
<jar jarfile="${jar}/HelloWorld.jar"
basedir="$(class)"
includes="**/*.class">
<manifest>
<attribute name="Main-Class" value="HelloWorld"/>
</manifest>
</jar>
</target>
<!-- running the programm -->
<target name="run" depends="jar">
<java jar="${jar}/HelloWorld.jar" fork="true">
</java>
</target>
<!-- deleting temporary (= redundant!) directories and content -->
<target name="clean">
<delete dir="${class}"/>
<delete dir="${jar}"/>
</target>
</project>
Can somebody help me?