|
RHS |
Classpath
Problems?
Do you get a strange error messages like "Cannot
resolve symbol" concerning
a class that you know is compiled and ready for use when you compile
your java class in Textpad?
Or do you get an "NoClassDefFoundError" exception when you try to run your program from Textpad?
Chances are that your classpath isn't set properly.
Classpath
The classpath is actually a string that holds a sequence of paths that
the compiler and/or java virtual machine (JVM) will look into to find
needed class-files (typically classes that you compiled to be used
in other classes).
The individual paths in the classpath are separated
by semicolon - it's important to note that space is not allowed between
paths in the classpath. The exception is if space is part of a path -
in which case the path (not including the semicolon) should be embedded in
double-quotes. It must be noted that the syntax concerning (at least) the
space differs in various versions of Windows (and DOS). It is adviceable
(not only because of the classpath) to avoid folder names that include
space (and other special characters) if possible.
So c:\programs\someApp;c:\j2sdk1.4.2\bin; is
a classpath containing two paths: c:\programs\someApp and c:\j2sdk1.4.2\bin.
And d:\superApp;d:\;"c:\program files\junit\junit3.8.1"; is
a classpath containing three paths: d:\superApp, d:\ and c:\program
files\junit\junit3.8.1.
Period
A special "path" is "." (period, dot or full stop). In
Windows (and other operating systems like Linux) this means "the current
folder" (or "the
current directory").
If you get errors like the ones mentioned above your classpath most likely misses the "." path.
Alter classpath
In the following I'll show you how you can alter the classpath in Windows
XP. In other versions this is done in a similar way even if some details
can be different (consult the documentation).
After you have altered a classpath you must normally restart Textpad before the change is effectuated - sometimes you must even restart other applications if you started Textpad through them (e.g. Explorer). If everything else fails a restart of the computer itself should do the trick!
More specifically I'll show you how to add the "." path to a classpath.
| First activate the control panel: | |||
![]() |
|||
Then choose "System": |
|||
![]() |
|||
In the dialogbox choose the "Advanced" tab and click the "Environment Variables" button: |
|||
![]() |
|||
In the buttom half, "System variables" you should see the variable classpath and its value. If variable classpath doesn't exist click the "New" button to create it. To change the value of the variable double-click on the line containing the name and value: |
|||
![]() |
|||
Now you can edit the string. |
|||
![]() |
|||
REMEMBER not to delete anything - just add ".;" in the beginning of the string (that way the current folder is the first place to be searched when the compiler or JVM uses the classpath).
Click "OK" to all the dialogboxex, restart Textpad and you should be going!