| View previous topic :: View next topic |
| Author |
Message |
logiclips@yahoo.com Guest
|
Posted: Fri Oct 28, 2005 1:50 pm Post subject: Package, ANT and Eclipse |
|
|
Hi,
I have a small problem concerning ANT and Eclipse:
I have a project in Eclipse with one package and just one .java file
(e.g. HelloWorld.java) in it. The first line in this file is "package
test.mypackage;"
When I compile and execute it in Eclipse I have no problems but when I
do the same with ANT I get the following error:
java.lang.NoClassDefFoundError: HelloWorld (wrong name:
test/mypackage/HelloWorld)
A part of the build.xml file look like this:
<target name="compile">
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="run" depends="compile">
When I remove the first line ("package test.mypackage;") of my
java-file it works. But then all my class files are stored in one
directory without any package structure and I can not compile the code
in Eclipse any more.
Why is that? How can I overcome this?
Thanks in advance,
Peter Vermeer
|
|
| Back to top |
|
 |
Jan Peter Stotz Guest
|
Posted: Fri Oct 28, 2005 3:25 pm Post subject: Re: Package, ANT and Eclipse |
|
|
[email]logiclips (AT) yahoo (DOT) com[/email] schrieb:
| Quote: | I have a project in Eclipse with one package and just one .java file
(e.g. HelloWorld.java) in it. The first line in this file is "package
test.mypackage;"
target name="run" depends="compile"
java classname="TextEditor" classpath="${build}/test/mypackage/"/
|
You classpath is wrong. If have to use classpath="${build}". The
subdirectory test/package will be converted to the package test.package by
the java runtime.
Jan
|
|
| Back to top |
|
 |
logiclips@yahoo.com Guest
|
Posted: Fri Oct 28, 2005 4:46 pm Post subject: Re: Package, ANT and Eclipse |
|
|
I did that but then I get this error message:
"Could not find TextEditor. Make sure you have it in your classpath"
Isn't the classpath the path to the .class files?
P.S. "HelloWorld" = "TextEditor"
Peter
|
|
| Back to top |
|
 |
Oliver Wong Guest
|
Posted: Fri Oct 28, 2005 4:52 pm Post subject: Re: Package, ANT and Eclipse |
|
|
<logiclips (AT) yahoo (DOT) com> wrote
| Quote: | I did that but then I get this error message:
"Could not find TextEditor. Make sure you have it in your classpath"
Isn't the classpath the path to the .class files?
|
No, it's actually the path to the directory that is the parent of the
root package where your class files are located (or sometimes it's a path to
a JAR file that contains the class files).
- Oliver
|
|
| Back to top |
|
 |
logiclips@yahoo.com Guest
|
Posted: Fri Oct 28, 2005 5:34 pm Post subject: Re: Package, ANT and Eclipse |
|
|
Well, but then this should be right:
<target name="compile">
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="run" depends="compile">
<java classname="TextEditor" classpath="${build}" ></java>
</target>
when I just only have one package as discribed above.
What is wrong?
Thanks,
Peter
|
|
| Back to top |
|
 |
logiclips@yahoo.com Guest
|
Posted: Fri Oct 28, 2005 6:16 pm Post subject: Re: Package, ANT and Eclipse |
|
|
OK, I've got it.
It has to be like this:
<target name="run" depends="compile">
Peter
|
|
| Back to top |
|
 |
|