Page 1 of 2

java.lang.NoClassDefFoundError

Posted: Tue Jan 07, 2003 5:31 pm
by Steven
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

Posted: Wed Jan 08, 2003 10:09 am
by Henrik S. Larsen
Make sure that you have et dot (.) in your classpath
Like CLASSPATH=.;AndWhatEverYouNeedHere

Re: java.lang.NoClassDefFoundError

Posted: Tue Jan 14, 2003 7:03 pm
by Garrett
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.

Re: java.lang.NoClassDefFoundError

Posted: Mon Jan 20, 2003 8:29 pm
by tiger lee
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

Re: java.lang.NoClassDefFoundError

Posted: Mon Jan 20, 2003 9:31 pm
by Garrett
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...

Re: java.lang.NoClassDefFoundError

Posted: Mon Jan 20, 2003 11:53 pm
by tiger lee
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

Re: java.lang.NoClassDefFoundError

Posted: Fri Jan 24, 2003 3:46 pm
by Garrett
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.

Re: java.lang.NoClassDefFoundError

Posted: Sun Feb 02, 2003 11:15 pm
by Eric
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)

Thanks

Posted: Fri Apr 04, 2003 12:54 pm
by L D
All I needed was the ;.; added to my CLASSPATH.
:P

Re: Thanks

Posted: Wed Oct 27, 2004 7:04 pm
by alienscum
L D wrote:All I needed was the ;.; added to my CLASSPATH.
:P
What is CLASSPATH?
Where do I find that?

I also have this problem. :(

Posted: Thu Oct 28, 2004 12:18 am
by s_reynisson
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.

I need help!!!

Posted: Sat Sep 24, 2005 11:56 pm
by gadha
I have the same problem, but someone guide me through this problem and help me fix it?

Got it to work!!!

Posted: Sun Sep 25, 2005 4:36 pm
by dhopp5
:D

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.

Posted: Sun Feb 26, 2006 1:18 pm
by TRXnMe
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

Posted: Sun Feb 26, 2006 1:42 pm
by TRXnMe
Grovelling apologies, figured it out. I'd got a small g in Kindergarten and a capital G in the damned file name :(

java appears to have a whole load of new ways for me to make a fool of my self :( ;)