java.lang.NoClassDefFoundError

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Steven

java.lang.NoClassDefFoundError

Post 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?
Henrik S. Larsen

Re: java.lang.NoClassDefFoundError

Post by Henrik S. Larsen »

Make sure that you have et dot (.) in your classpath
Like CLASSPATH=.;AndWhatEverYouNeedHere
Garrett

Re: java.lang.NoClassDefFoundError

Post 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.
tiger lee

Re: java.lang.NoClassDefFoundError

Post 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
Garrett

Re: java.lang.NoClassDefFoundError

Post 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...
tiger lee

Re: java.lang.NoClassDefFoundError

Post 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
Garrett

Re: java.lang.NoClassDefFoundError

Post 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.
Eric

Re: java.lang.NoClassDefFoundError

Post 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)
L D
Posts: 2
Joined: Fri Apr 04, 2003 6:55 am

Thanks

Post by L D »

All I needed was the ;.; added to my CLASSPATH.
:P
alienscum

Re: Thanks

Post 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. :(
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post 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.
Then I open up and see
the person fumbling here is me
a different way to be
gadha
Posts: 2
Joined: Fri Sep 16, 2005 2:47 pm

I need help!!!

Post by gadha »

I have the same problem, but someone guide me through this problem and help me fix it?
dhopp5
Posts: 1
Joined: Sun Sep 25, 2005 4:31 pm
Location: Chicago

Got it to work!!!

Post 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.
Regards,
David
TRXnMe
Posts: 2
Joined: Sun Feb 26, 2006 1:11 pm
Location: South Wales

Post 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
If beer is so bad for brain cells, why does my brain let me drink so much of it???
TRXnMe
Posts: 2
Joined: Sun Feb 26, 2006 1:11 pm
Location: South Wales

Post 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 :( ;)
If beer is so bad for brain cells, why does my brain let me drink so much of it???
Post Reply