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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems starting java application with ant

Status
Not open for further replies.

redbaron11

Programmer
Dec 14, 2006
1
0
0
AT
I have a simple HelloWorld application, which i want to start with ant. Here the ant build.xml:

<project name="test" default ="run-helloworld">
<target name="run-helloworld">
<java classname="build/HelloWorld" fork="true" />
</target>
</project>

HelloWorld.class is saved in the directory build. if i run ant, i get exceptions, listed below:

Buildfile: build.xml

run-helloworld:
[java] java.lang.NoClassDefFoundError: build/HelloWorld (wrong name: HelloW
orld)
[java] at java.lang.ClassLoader.defineClass1(Native Method)
[java] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
[java] at java.security.SecureClassLoader.defineClass(SecureClassLoader
.java:124)
[java] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
[java] at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
[java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

[java] Exception in thread "main"
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 0 seconds


But, if i save my HelloWorld.class in the root directory and change the ant build.xml, everything is fine:

<project name="test" default ="run-helloworld">
<target name="run-helloworld">
<java classname="HelloWorld" fork="true" />
</target>
</project>

if i run it:

Buildfile: build.xml

run-helloworld:
[java] Hello World

BUILD SUCCESSFUL
Total time: 0 seconds

How i have to implement the path to my directories, that it will work? Have you some hints for me?

Thanks and greetings,
redbaron

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top