Created a jar archive using ANT. Build code:
<?xml version="1.0"?> <project name="HelloWorld" default="run"> <!-- define names of directories --> <property name="src" location="src"/> <property name="build" location="build"/> <property name="classes" location="${build}/classes"/> <!-- define all targets --> <target name="hello"> <echo>Hello, World!</echo> </target> <target name="compile"> <mkdir dir="${classes}"/> <javac srcdir="${src}" destdir="${classes}" includeAntRuntime="false"/> </target> <target name="run" depends="hello, compile"> <java classname="${ant.project.name}" classpath="${classes}"/> </target> <target name="clean"> <delete dir="${build}"/> </target> <target name="package" depends="compile"> <jar destfile="${build}/${ant.project.name}.jar" basedir="${classes}"> <manifest> <attribute name="Main–Class" value="${ant.project.name}"/> </manifest> </jar> </target> </project>
A HelloWorld.jar file was created with the manifest MANIFEST.MF with the code:
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.10.1 Created-By: 1.8.0_131-b11 (Oracle Corporation) Main–Class: HelloWorld
Now when by hand in the console from the place where the folder SRC and BUILD run:
java -jar build/HelloWorld.jar
then the following error appears:
Error: An unexpected error occurred while trying to open file build/HelloWorld.jar
environment variables rechecked JAVA_HOME and PATH specified path to the bin folder of JDK1.8
Help me figure out why the HelloWorld file isn't running?