dcsimg
Problems with path to java files when using ant.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   red_baron
Posted On:   Thursday, December 14, 2006 12:31 PM

I have a simple HelloWorld application, which i want to start with ant. Here the ant build.xml: 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: HelloWorld) [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   More>>

I have a simple HelloWorld application, which i want to start with ant. Here the ant build.xml:
















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: HelloWorld)

[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:














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

   <<Less

Re: Problems with path to java files when using ant.

Posted By:   Anonymous  
Posted On:   Monday, December 18, 2006 09:33 AM

You could be interested in Manual::Tutorial: Hello World with Ant

Re: Problems with path to java files when using ant.

Posted By:   Robert_Lybarger  
Posted On:   Thursday, December 14, 2006 09:04 PM

You just need to specify the equivalent to a CLASSPATH in your java task. Check the docs. I'll assume your class does not declare a package; if I'm right, try this...

...





...
About | Sitemap | Contact