LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-17-2006, 01:17 PM   #1
rlnd
Member
 
Registered: Aug 2004
Posts: 33

Rep: Reputation: 15
java.lang.NoclassDefFoundError


I've MDK, Java Sun and Netbeans IDE.
The programs (*.class) into my folder "PgmSRC" work fine ( but I have to write "package PgmSRC" into the *.java file ) while the programs into other folders (that are contained in PgmSRC ) get "Exception in thread "main" java.lang.NoclassDefFoundError " though I write "package foldername".....
How can be set Classpath (...if this is the problem) ?
Thanks for your helps......
 
Old 02-17-2006, 02:38 PM   #2
scorbett
Member
 
Registered: May 2002
Location: Canada
Distribution: Slackware, Mandriva, RedHat
Posts: 46

Rep: Reputation: 15
Set the environment variable CLASSPATH to include the directory that contains your package directory. Or, start java with the "-classpath" options:

java -classpath c:\code\ MyPackage.MyClass
 
Old 02-17-2006, 03:15 PM   #3
rlnd
Member
 
Registered: Aug 2004
Posts: 33

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by scorbett
Set the environment variable CLASSPATH to include the directory that contains your package directory. Or, start java with the "-classpath" options:

java -classpath c:\code\ MyPackage.MyClass
It seems to be a windows command.............
 
Old 02-17-2006, 04:00 PM   #4
scorbett
Member
 
Registered: May 2002
Location: Canada
Distribution: Slackware, Mandriva, RedHat
Posts: 46

Rep: Reputation: 15
Sorry, forgot I was in a Linux forum:

java -classpath /home/me/source MyPackage.MyClass
But now that I re-read your original message, I see you are using NetBeans, so instead of doing what I suggested you should set the classpath in the IDE instead (sorry I don't use NetBeans so I don't know exactly where to set it, search the manual for CLASSPATH).
 
Old 02-17-2006, 10:38 PM   #5
Fredstar
Member
 
Registered: Jul 2004
Location: Rochester, NY
Distribution: Fedora9::FreeBSD7.1
Posts: 296

Rep: Reputation: 30
Instead of creating my own post i figure i would hop on this one since it is the same problem.

Ok well im on a windows machine. Yes, yes, i know "linux forum" but until Asus sends me back my MOBO im going to have to use my mothers work computer.

Now im having the same exact problem. in class at school we normally just -cp C:\location\to\class\file\Myclass.class and bam.

On suse i didnt have this problem but im having it on windows where im getting the same error as above. Any help would be appreciated.

thanks

**edit**solved***

Ok Ok, for some reason the command line -cp was not working.

So to get it working cd to the document folder and then

"set classpath=." (without the "")

tada all works and the world is once more a good place!!

Now all i need is my computer back!!

Last edited by Fredstar; 02-17-2006 at 10:53 PM.
 
Old 02-18-2006, 04:54 AM   #6
HalkEkmek
LQ Newbie
 
Registered: Sep 2005
Location: Turkey
Distribution: ubuntu
Posts: 11

Rep: Reputation: 0
On linux you can set your classpath in your .bashrc file adding the commands below.
"/opt/jdk1.5.0_04" is my jdk path. Replace your path with it.

export PATH=/opt/jdk1.5.0_04/bin:$PATH
export JAVA_HOME="/opt/jdk1.5.0_04"
export CLASSPATH=.:/opt/jdk1.5.0_04
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java exception: java.lang.NoClassDefFoundError kath Programming 12 05-11-2006 04:37 AM
java.lang.InstantiationException: java.sql.Connection poeta_boy Programming 2 07-06-2005 08:26 PM
Exception in thread "main" java.lang.NoClassDefFoundError: Lobais Linux - Software 19 06-23-2004 08:42 AM
Exception in thread "main" java.lang.NoClassDefFoundError: melinda_sayang Programming 2 04-27-2004 11:49 AM
I've set the CLASSPATH, but I still get a noClassDefFoundError. (Java) Travis86 Programming 6 02-05-2004 09:09 AM


All times are GMT -5. The time now is 07:50 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration