java.lang.NoClassDefFoundError
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
java.lang.NoClassDefFoundError
I have installed J2sdk1.4.1_01. The class compiles correctly but when I run it I get a NoClassDefFoundError. Does anyone know how to load the java libraries into textpad?
Re: java.lang.NoClassDefFoundError
Make sure that you have et dot (.) in your classpath
Like CLASSPATH=.;AndWhatEverYouNeedHere
Like CLASSPATH=.;AndWhatEverYouNeedHere
Re: java.lang.NoClassDefFoundError
It's also possible that you need to set up your execution directories properly. TextPad's initial configuration with it's COMPILE JAVA, RUN JAVA APPLICATION, and RUN JAVA APPLET tools assume that you have _NO PACKAGES_.
If you do, and you don't want to have to explicitly edit your classpath to point at the root of your class directory, (the one that contains the directory /com/,) then you should edit the config of the JAVA commands. For example, I have my commands set up like this:
COMPILE JAVA:
PARAMETERS: -classpath ..\.. $File
INITIAL FOLDER: $FileDir
RUN JAVA APPLICATION:
PARAMETERS: com.mypackage.$BaseName
INITIAL FOLDER: $FileDir\..\..
These params tell TextPad to shoot back up to the top of the directory structure before looking for the packaged classes I'm using when compiling, while when running it tells TextPad to shoot up to the root directory. I find this preferable to editing my classpath whenever I create a new directory of java files.
Of course, this is all moot if you're not using packages.
If you do, and you don't want to have to explicitly edit your classpath to point at the root of your class directory, (the one that contains the directory /com/,) then you should edit the config of the JAVA commands. For example, I have my commands set up like this:
COMPILE JAVA:
PARAMETERS: -classpath ..\.. $File
INITIAL FOLDER: $FileDir
RUN JAVA APPLICATION:
PARAMETERS: com.mypackage.$BaseName
INITIAL FOLDER: $FileDir\..\..
These params tell TextPad to shoot back up to the top of the directory structure before looking for the packaged classes I'm using when compiling, while when running it tells TextPad to shoot up to the root directory. I find this preferable to editing my classpath whenever I create a new directory of java files.
Of course, this is all moot if you're not using packages.
Re: java.lang.NoClassDefFoundError
My OS is windows 2000 professional with service pack 3. compiles java in Tools is ok. but Run java application does not work.
and I use:
RUN JAVA APPLICATION:
PARAMETERS: com.mypackage.$BaseName
INITIAL FOLDER: $FileDir\..\..
and still get a NoClassDefFoundError.
but in the DOS mode the java works well.
who knows the reason?
regards
and I use:
RUN JAVA APPLICATION:
PARAMETERS: com.mypackage.$BaseName
INITIAL FOLDER: $FileDir\..\..
and still get a NoClassDefFoundError.
but in the DOS mode the java works well.
who knows the reason?
regards
Re: java.lang.NoClassDefFoundError
I'm still not clear: Is your class using packages or no? If you're using packages, you need to tell me the package DEPTH. That's to say, is it:
com.mypacage.MyClass
OR
com.mypackage.mysubpackage.MyClass
OR
com.mypackage.mysubpackage1.mysubpackage2.MyClass
etc, etc, etc....
That impacts HOW MANY directories you recurse UPWARDS.
Also, be sure your CLASSPATH variable's set properly:
It must include the current directory, defined by 'dot':
CLASSPATH = ".;C:\myjavadir1;C:\myjavadir2;C:\myjardir\jar1.jar........"
I've not enough information to help you further...
com.mypacage.MyClass
OR
com.mypackage.mysubpackage.MyClass
OR
com.mypackage.mysubpackage1.mysubpackage2.MyClass
etc, etc, etc....
That impacts HOW MANY directories you recurse UPWARDS.
Also, be sure your CLASSPATH variable's set properly:
It must include the current directory, defined by 'dot':
CLASSPATH = ".;C:\myjavadir1;C:\myjavadir2;C:\myjardir\jar1.jar........"
I've not enough information to help you further...
Re: java.lang.NoClassDefFoundError
I just run the HelloWorld.java. In the textpad I can only compile but I can not run by click the run java application button.
regards
regards
Re: java.lang.NoClassDefFoundError
OK, it could be this:
You've not set your CLASSPATH variable properly. You need to make sure that the CLASSPATH environment variable, accessible through System Properties-->Environment Variables-->User Variables.
MAKE SURE that it includes a single 'dot' delimited by semicolons, like one of these examples:
.;C:\Javaclasses\;C:\Javaclasses\classes.jar
or
C:\Javaclasses;.;C:\Javaclasses\classes.jar
etc. etc. etc...
If you have no CLASSPATH set under User variables, create one, with just a dot as the value.
AND get rid of the whole com.mypackage stuff. It doesn't apply. Also get rid of the \..\.. stuff. Just use $BaseName as your parameter, and $FileDir as your working directory.
You've not set your CLASSPATH variable properly. You need to make sure that the CLASSPATH environment variable, accessible through System Properties-->Environment Variables-->User Variables.
MAKE SURE that it includes a single 'dot' delimited by semicolons, like one of these examples:
.;C:\Javaclasses\;C:\Javaclasses\classes.jar
or
C:\Javaclasses;.;C:\Javaclasses\classes.jar
etc. etc. etc...
If you have no CLASSPATH set under User variables, create one, with just a dot as the value.
AND get rid of the whole com.mypackage stuff. It doesn't apply. Also get rid of the \..\.. stuff. Just use $BaseName as your parameter, and $FileDir as your working directory.
Re: java.lang.NoClassDefFoundError
I got the same problem, and I solved it simply by reinstalling the Java 2 SDK into a path like this: C:\Java\J2SDK (notice there is no space in the path)
Re: Thanks
What is CLASSPATH?L D wrote:All I needed was the ;.; added to my CLASSPATH.
Where do I find that?
I also have this problem.
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm
Ok, I finally took a second look at your post and saw your edit's.
You should remove/delete all your java tools from TP and use TP to add them, then you will get the correct parameters for each tool, see the java FAQ here - http://textpad.com/support/faq/java.html - "How do I add the JDK commands?".
This should also fix the "jump from a compile error" problem as you will get the correct regex to match output.
I hope this helps.
You should remove/delete all your java tools from TP and use TP to add them, then you will get the correct parameters for each tool, see the java FAQ here - http://textpad.com/support/faq/java.html - "How do I add the JDK commands?".
This should also fix the "jump from a compile error" problem as you will get the correct regex to match output.
I hope this helps.
Then I open up and see
the person fumbling here is me
a different way to be
the person fumbling here is me
a different way to be
I need help!!!
I have the same problem, but someone guide me through this problem and help me fix it?
Got it to work!!!
Thank you for your posts. I got it to work. One of the most frustrating things I find in java is typos....
To set the class path on 2000 and XP right click my computer; goto properties; click on advanced; click on Environmental variables; add a new variable (on the bottom half of the window)
CLASSPATH=.;C:\j2sdk1.4.2_09\bin
The j2sdk1.1.2_09 may be different depending on you current version of Java.
Regards,
David
David
Hello All, this is my first post in here, so please be gentle.
I've got the java.lang.NoClassDefFoundError problem with TextPad, now I've checkd out everything mentioned in this thread sn it's not helped. What makes me more confused is that I have one programme that works and one that doesn't......
Working code: -
public static void main (String [] args) {
//start the program running from its constructor
new CurioStore1 ();
Not working code: -
//main method of programme
public static void main (String [] args) {
new Kindergarten ();
AS both pieces of code and both class files are in the folder I'm not sure that it is the CLASSPATH issue, but I've set the CLASSPATH as . anyway, still no progress.
This is driving me up the wall as it looks to be very simple, but the thing still wont work!!!
Any help greatly appreciated.
Thanks
Iaqn
I've got the java.lang.NoClassDefFoundError problem with TextPad, now I've checkd out everything mentioned in this thread sn it's not helped. What makes me more confused is that I have one programme that works and one that doesn't......
Working code: -
public static void main (String [] args) {
//start the program running from its constructor
new CurioStore1 ();
Not working code: -
//main method of programme
public static void main (String [] args) {
new Kindergarten ();
AS both pieces of code and both class files are in the folder I'm not sure that it is the CLASSPATH issue, but I've set the CLASSPATH as . anyway, still no progress.
This is driving me up the wall as it looks to be very simple, but the thing still wont work!!!
Any help greatly appreciated.
Thanks
Iaqn
If beer is so bad for brain cells, why does my brain let me drink so much of it???