*
The moose likes Beginning Java and the fly likes [Agile Java - Langr, p127] Class not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "[Agile Java - Langr, p127] Class not found "sis.AllTests"" Watch "[Agile Java - Langr, p127] Class not found "sis.AllTests"" New topic
Author

[Agile Java - Langr, p127] Class not found "sis.AllTests"

Mark Pawelek
Greenhorn

Joined: Sep 03, 2010
Posts: 4
[Agile Java - Langr, p127]

Working through the long tutorial, I've got to page 127. After creating the new directory structure, moving the files and refactoring, I can't run my java program. The first line compiles with no problems. [Appendix 1]

The 2nd line consistently gives an error message [Class not found "sis.AllTests"]


Appendix 1: Java compile and command to execute all tests:

javac -classpath .\sis;.\sis\studentinfo;.\sis\report;C:\Programs\junit4.9\junit-4.9.jar sis\studentinfo\*.java sis\report\*.java sis\*.java
java -classpath .\sis;.\sis\studentinfo;.\sis\report;C:\Programs\junit4.9\junit-4.9.jar junit.textui.TestRunner sis.AllTests


Appendix 2: New directory structure


--sis
|
+--- report
|
+--- studentinfo


Appendix 3: Source for the class that "can't be found". Note that the first line from Appendix 1 produces a .class file in the same directory [sis].

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just FYI, if you give the root of a classpath, you don't need to give its sub-packages/dirs as well.

But the root cause is that you're giving the classpath as ".\sis" when it should just be ".", the current directory. Since the package of the class is "sis", it's going to look for the class in ".\sis\sis" as it's assuming ".\sis" is a root classpath, but it isn't: the current directory is.
Mark Pawelek
Greenhorn

Joined: Sep 03, 2010
Posts: 4
Thanks.

This worked:

javac -classpath .\sis;.\sis\studentinfo;.\sis\report;C:\Programs\junit4.9\junit-4.9.jar sis\studentinfo\*.java sis\report\*.java sis\*.java
java -classpath .\;C:\Programs\junit4.9\junit-4.9.jar junit.textui.TestRunner sis.AllTests

Nevertheless, I managed to get the ant build going as well so I no longer need the batch file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Agile Java - Langr, p127] Class not found "sis.AllTests"
 
Similar Threads
Want to run multiple Test Cases by Ant ?
[JUnit] Could not find the main class junit.awtui.TestRunner
How to create a new suit with only selected tests from other suite
Question on addTest method of Junit
Test Suites