Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>cd ..
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann>cd ..
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>tree
Folder PATH listing
Volume serial number is 00730065 D80F:8634
C:.
└───horstmann
└───samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>javac -classpath \horstmann\samples horstmann\samples\*.java
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>cd horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>javac JFileChooser error: Class names, 'JFileChooser', are only accepted if annotation processing i
s explicitly requested 1 error
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>javac JFileChooserTest
error: Class names, 'JFileChooserTest', are only accepted if annotation processi
ng is explicitly requested
1 error
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>edit FileChooserTest.java
The system cannot execute the specified program.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>del *.class
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>type FileChooserTest.java
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
Jesper de Jong wrote:You should run that like this:
cd C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
java horstmann.samples.FileChooserTest
You must be in the base directory of the package and specify the fully-qualified class name with the java command.
I still get this error, and, I also tried setting the environment variable CLASSPATH to ".", for testing only, because Corstmann recommends that the CLASSPATH variable should be set and unset carefully by installation scripts, since they might obviously affect the location of the Java library files required to run the JVM.
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>java horstmann.samples.FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann/samples/Fil
eChooserTest
Caused by: java.lang.ClassNotFoundException: horstmann.samples.FileChooserTest
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)
Could not find the main class: horstmann.samples.FileChooserTest. Program will
exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Jon>cd workspace
C:\Documents and Settings\Jon\workspace>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>cd horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>java horstmann.samples.FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann/samples/Fil
eChooserTest
Caused by: java.lang.ClassNotFoundException: horstmann.samples.FileChooserTest
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)
Could not find the main class: horstmann.samples.FileChooserTest. Program will
exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>cd ..
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>java horstmann\samples\FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann\samples\Fil
eChooserTest (wrong name: FileChooserTest)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
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)
Could not find the main class: horstmann\samples\FileChooserTest. Program will
exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>java horstmann.samples.FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann/samples/Fil
eChooserTest (wrong name: FileChooserTest) at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
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)
Could not find the main class: horstmann.samples.FileChooserTest. Program will
exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>echo %CLASSPATH%
.;.;C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\P
ROGRA~1\JMF21~1.1E\lib;
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>set CLASSPATH = .
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>java horstmann\samples\JFileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann\samples\JFi
leChooserTest
Caused by: java.lang.ClassNotFoundException: horstmann\samples\JFileChooserTest
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)
Could not find the main class: horstmann\samples\JFileChooserTest. Program will
exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest should be the directory to run your applications from - the folder in which the package folders are located.
Rob Spoor wrote:C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest should be the directory to run your applications from - the folder in which the package folders are located.
Thanks, I got the sequence right finally
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>prompt $g
>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09>cd FileChooserT
est
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>java horstmann.samples FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann/samples
Caused by: java.lang.ClassNotFoundException: horstmann.samples
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)
Could not find the main class: horstmann.samples. Program will exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>cd horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>java horstmann.samples FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann/samples
Caused by: java.lang.ClassNotFoundException: horstmann.samples
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)
Could not find the main class: horstmann.samples. Program will exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>java FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: FileChooserTest (wron
g name: horstmann/samples/FileChooserTest)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
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)
Could not find the main class: FileChooserTest. Program will exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>java FileChooserTest
Exception in thread "main" java.lang.NoClassDefFoundError: FileChooserTest (wron
g name: horstmann/samples/FileChooserTest)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
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)
Could not find the main class: FileChooserTest. Program will exit.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>type JFileChooser.java
The system cannot find the file specified.
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>del *.class
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann\samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>type del_class.bat
@echo off
del *.class
pause
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann\samples>cd ..
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest\horstmann
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
\horstmann>cd ..
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>dir
Volume in drive C has no label.
Volume Serial Number is D80F-8634
Directory of C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\F
ileChooserTest
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>compile.bat
Could Not Find C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\
FileChooserTest\horstmann\samples\*.class
Exception in thread "main" java.lang.NoClassDefFoundError: horstmann/samples
Caused by: java.lang.ClassNotFoundException: horstmann.samples
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)
Could not find the main class: horstmann.samples. Program will exit.
Press any key to continue . . .
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>type compile.bat
@echo off
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>tree
Folder PATH listing
Volume serial number is 00730065 D80F:8634
C:.
└───horstmann
└───samples
C:\Documents and Settings\Jon\workspace\JavaDev\corejava8\v1ch09\FileChooserTest
>