×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problems starting java application with ant

Problems starting java application with ant

Problems starting java application with ant

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close