AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Package, ANT and Eclipse

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
logiclips@yahoo.com
Guest





PostPosted: Fri Oct 28, 2005 1:50 pm    Post subject: Package, ANT and Eclipse Reply with quote



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">
Quote:
/java
/target



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





PostPosted: Fri Oct 28, 2005 3:25 pm    Post subject: Re: Package, ANT and Eclipse Reply with quote



[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





PostPosted: Fri Oct 28, 2005 4:46 pm    Post subject: Re: Package, ANT and Eclipse Reply with 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?


P.S. "HelloWorld" = "TextEditor"


Peter

Back to top
Oliver Wong
Guest





PostPosted: Fri Oct 28, 2005 4:52 pm    Post subject: Re: Package, ANT and Eclipse Reply with quote


<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





PostPosted: Fri Oct 28, 2005 5:34 pm    Post subject: Re: Package, ANT and Eclipse Reply with quote

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





PostPosted: Fri Oct 28, 2005 6:16 pm    Post subject: Re: Package, ANT and Eclipse Reply with quote

OK, I've got it.

It has to be like this:

<target name="run" depends="compile">
Quote:
/java
/target


Peter


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.