news wrote:
I use the command line as follows:
c:\j2sdk1.4.2_03\bin\java d:\personal\java-ChartGen\TestChart.class
The full error message is as follows:
Exception in thread "main" java.lang.NoClassDefFoundError:
d:\personal\java-ChartGen\TestChart/class
I thought it may be the CLASSPATH, but all my class files are located in the
same folder and I used the switch -classpath but the same error comes up.
You've got a few responses, but I don't think they clearly explain the
issue, so I'll pop in. The Java VM expects a class name as it argument.
A class name is:
1. NOT a filename for a class file.
2. NOT the same as a filename minus the extension.
Instead of any of the above, it's a fully qualified class name. That
means the identifier that you put after the 'class' keyword in the
source file where you wrote the class, prefixed by the dot-delimited
string of identifiers after your 'package' keyword, if there is one.
Any "path" information shouldn't be there, period.
The source of confusion is that there are also a few rules that relate
the name of a class to how it's found by the VM. Those are incidental.
The classpath (set by an environment variable or command line option, or
various other implicit rules) determines at a basic level where the
class is found. The class name is the parameter, and it doesn't
duplicate the purpose of the classpath.
For this reason, I think it's helpful to say "use the class name, not a
file name" and that it's potentially quite confusing to say "leave off
the extension". After all, your command would still not have worked
even without the extension. Why? Because it's still not the class
name.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation