Problem with classpath

Guys,

I am in need of explanation on the command line statement to run the following programme (from a book). The location (package structure) of the programme is shown in the screen shot of a DOS window below. I have used asterics to delineate the sections for easy copying.

Please, show me how you are able to run the programme from the command line.

Thanks,

ue-Joe

*******************************************************************************************

// joejava/util/tools/Print.java

// Print methods that can be used without qualifiers, using Java SE5 static imports:

package joejava.util.tools;

import java.io.*;

public class Print

{

// Print with a newline.

public static void print(Object obj)

{

System.out.println(obj);

}

// Print a newline itself.

public static void print()

{

System.out.println();

}

// Print with no line break.

public static void printnb(Object obj)

{

System.out.print(obj);

}

// The Java SE5 printf()(from C)

public static PrintStream printf(String format, Object... args)

{

return System.out.printf(format, args);

}

}

**************************************************************************************

import static joejava.util.tools.Print.*;

public class PrintTest

{

public static void main(String[] args)

{

print("Available from now on!");

print();

print(100);

print();

print(100L);

print();

print(3.14159);

print();

printf("%d \n", 3.14159);

}

}

*************************************************************************************

C:\joejava\util\tools>dir

Volume in drive C has no label.

Volume Serial Number is F4E5-2352

Directory of C:\joejava\util\tools

06/26/2007 02:22 AM<DIR> .

06/26/2007 02:22 AM<DIR> ..

06/25/2007 02:58 AM650 Print.class

06/26/2007 02:23 AM111 Print.jar

06/25/2007 02:52 AM826Print.java

06/25/2007 08:17 PM757 PrintTest.class

06/25/2007 02:56 AM285PrintTest.java

5 File(s) 2,629 bytes

2 Dir(s) 25,246,867,456 bytes free

C:\joejava\util\tools>java PrintTest

Exception in thread "main" java.lang.NoClassDefFoundError: joejava/util/tools/Print

at PrintTest.main(PrintTest.java:7)

C:\joejava\util\tools>java -jar PrintTest.jar

Unable to access jarfile PrintTest.jar

C:\joejava\util\tools>

**************************************************************************************

[2724 byte] By [ue_Joea] at [2007-11-27 8:48:36]
# 1

Well i believe for executing u have to work on one directory up than the directory where u have ur files..... u go one directory up and then give the java file name with the package name....Command>>java pachage.filename

this should execute properly.. i hope this works.. and hope iam tellin the right thing... if iam wrong then please do correct me.. thnx!!

power-extremea at 2007-7-12 20:56:01 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks for the suggestion. I have tried it but it did not work. I still get the same error message. I will appreciate further suggestions.ue_Joe.
ue_Joea at 2007-7-12 20:56:01 > top of Java-index,Java Essentials,New To Java...
# 3

Go to the directory which contains "joejava" and try invoking it with java from there.

(I manipulated Print to incorporate some stuff from PrintTest to get this much to execute.)

From the directory with "joejava":

C:\Eclipse Workspace\TestStuff>java joejava/util/tools/Print

Available from now on!

100

100

3.14159

From the directory that Print is in:

C:\Eclipse Workspace\TestStuff\joejava\util\tools>java Print

Exception in thread "main" java.lang.NoClassDefFoundError: Print (wrong name: joejava/util/tools/Print)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.access$000(Unknown Source)

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

jsf_onlinea at 2007-7-12 20:56:01 > top of Java-index,Java Essentials,New To Java...
# 4

Thank you very much. It worked. I think part of the problem was that I was using the back slash instead of the front slash. I actually thought they were interchangeable since I could use the back slash to cd to a directory. This has long caused several troubled moments for me. I simply followed your example and there it was - solution!

Once more, thank you all.

ue_Joe.

ue_Joea at 2007-7-12 20:56:01 > top of Java-index,Java Essentials,New To Java...