In a word...no. The package statment at the top of the .java file and the Java compiler also have a say in where the .class file goes. Looks like one of your files declares a package but the other does not; they both should.
On 5/3/05, Wim Vandewalle <[EMAIL PROTECTED]> wrote: > The POM is identical to the 10 minute test at the Maven site: > > <project> > <groupId>sample</groupId> > <artifactId>sample-echo</artifactId> > <version>1.0-SNAPSHOT</version> > <dependencies> > <dependency> > <groupId>log4j</groupId> > <artifactId>log4j</artifactId> > <version>1.2.8</version> > </dependency> > </dependencies> > <build> > <sourceDirectory>src/main/java</sourceDirectory> > <unitTestSourceDirectory>src/test/java</unitTestSourceDirectory> > <resources> > <resource> > <directory>src/main/resources</directory> > </resource> > </resources> > <unitTest> > <includes> > <include>**/*Test.java</include> > </includes> > </unitTest> > </build> > </project> > > If I understand this right, there is a problem with the destination location > of the class files: > > "main/java/" in: target/classes/main/java/code/TryIt.class > "test/java/" in: target/test-classes/test/java/TryitTest.class > > Isn't it up to Maven to decide where to put the class files? > > Wim > > > ---------------------------------------- > > From: Samuel Le Berrigaud <[EMAIL PROTECTED]> > > Sent: Tue May 03 12:12:21 CEST 2005 > > To: Maven Users List <users@maven.apache.org>, Wim Vandewalle <[EMAIL > > PROTECTED]> > > Subject: Re: Maven Junit test ClassNotFoundException > > > > > > Hi, > > > > there is something strange between your source files and your class files. > > > > Is the pakcage of Tryit.java the default package or the "code" package ? > > > > First I would say have the same directory structure inside your > > src/main and src/test, and the same package for the class being tested > > and the test class. > > > > Second, if your Tryit.java uses the default package it should then be: > > > > - target/classes/Tryit.class > > - target/test-classes/TryitTest.class > > > > if it uses the "code" pakcage it should be: > > > > - target/classes/code/Tryit.class > > - target/test-classes/code/TryitTest.class > > > > I think the exception comes from those points... > > I would need a extract of your pom (project.xml) to be more precise. > > > > SaM > > > > On 5/3/05, Wim Vandewalle <[EMAIL PROTECTED]> wrote: > > > Hi > > > > > > I started recently setting up a test with Maven. > > > I followed the steps described in "Getting started - Creating a project". > > > I added 2 simple classes: > > > > > > - src/main/java/code/Tryit.java > > > - src/test/java/TryitTest.java (unit test) > > > > > > The java classes compile ok: > > > > > > - target/classes/main/java/code/TryIt.class > > > - target/test-classes/test/java/TryitTest.class > > > > > > However when running the unit tests it looks like the test class is not > > > in JUnit's classpath: > > > > > > C:\repositories\eclipse\maventest>maven test:test > > > __ __ > > > | \/ |__ _Apache__ ___ > > > | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ > > > |_| |_\__,_|\_/\___|_||_| v. 1.0.2 > > > > > > build:start: > > > > > > java:prepare-filesystem: > > > > > > java:compile: > > > [echo] Compiling to C:\repositories\eclipse\maventest/target/classes > > > [echo] > > > ========================================================== > > > > > > NOTE: Targetting JVM 1.4, classes > > > will not run on earlier JVMs > > > > > > ========================================================== > > > > > > [javac] Compiling 1 source file to > > > C:\repositories\eclipse\maventest\target\classes > > > > > > java:jar-resources: > > > > > > test:prepare-filesystem: > > > > > > test:test-resources: > > > > > > test:compile: > > > [javac] Compiling 1 source file to > > > C:\repositories\eclipse\maventest\target\test-classes > > > > > > test:test: > > > [junit] Running > > > [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec > > > [junit] Testsuite: TryItTest > > > [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec > > > [junit] > > > [junit] Null Test: Caused an ERROR > > > [junit] TryItTest > > > [junit] java.lang.ClassNotFoundException: TryItTest > > > [junit] at java.net.URLClassLoader$1.run(URLClassLoader.java:199) > > > [junit] at java.security.AccessController.doPrivileged(Native > > > Method) > > > [junit] at > > > java.net.URLClassLoader.findClass(URLClassLoader.java:187) > > > [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:289) > > > [junit] at > > > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274) > > > [junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:235) > > > [junit] at > > > java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) > > > [junit] at java.lang.Class.forName0(Native Method) > > > [junit] at java.lang.Class.forName(Class.java:141) > > > [junit] > > > [junit] > > > [junit] [ERROR] TEST TryItTest FAILED > > > > > > BUILD FAILED > > > File...... C:\Documents and > > > Settings\wvdw\.maven\cache\maven-test-plugin-1.6.2\plugin.jelly > > > Element... fail > > > Line...... 181 > > > Column.... 54 > > > There were test failures. > > > Total time: 3 seconds > > > Finished at: Tue May 03 11:44:52 CEST 2005 > > > > > > Any ideas? > > > > > > Wim > > > ----------------------------------------------------- > > > Mail.be, WebMail and Virtual Office > > > http://www.mail.be > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > ----------------------------------------------------- > Mail.be, WebMail and Virtual Office > http://www.mail.be > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jamie Bisotti Software Engineer Lexmark International, Inc. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]