Register | Log in | RSS channel for codegravity.com homepage Bookmark!

232/2NEW projects | 71 services | 212 websites | 712/4NEW freelancers | 1994 topics | advertise



Login:



Forgot your password?
Forgot your username?
Create an account


Countries

17.8%United States United States
17.4%India India
8%Germany Germany
6.2%United Kingdom United Kingdom
5.2%France France

Visitors

Today: 2012
Yesterday: 2730
Last Week: 22801
This Month: 46708
Last Month: 38950
Total: 119692


Users

Most active users today from total of 65:
Butcher, irage, thenabster, rvblester, ajorge, wislo, solidexsi, aladino23, Gisbert, banjoroy, crazydude, danh6192, fry, cevyweemfex, brasovnet, Siphok, d.ernesto.jimenez, bobef90, Ropsha, Habstar
JoomlaWatch Stats 1.2.10_04 by Matej Koval
Partners:

Freelance ColdFusion, Flex, PHP

Olejomalby, abstraktne obrazy

Camping Europe

WinAsm Studio

Vyšné Ružbachy

Sochy, Reštaurovanie

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:
rss feed

Statistics:
Search Engine Genie Promotion Widget
Home

Exception in thread "main" java.lang.NoClassDefFoundError


A friend of mine wanted to start to learn java, and I wanted to help him, so we created a simple Hello World example.

public class Hello {

public static void main(String argv[]) {

System.out.println("Hello world !");

}

}

then, when you compile it:

> javac Hello.java

and want to execute it:

> java Hello

Exception in thread "main" java.lang.NoClassDefFoundError: Hello

We set the CLASSPATH and JAVA_HOME enviroment variable correctly, and the problem was still the same..
When we copied the Hello.class into a lib directory of JAVA_HOME, it worked, but not from the current directory !

We tried different versions of java.. and do you know where this stupid problem is?

in the CLASSPATH there should be:
CLASSPATH=.;c:\programme\jboss\lib;c:\programme\
j2sdk1.4.2_08\lib;c:\programme\j2sdk1.4.2_08\jre\lib; ...

yes.. a dot .. it means, that it will search for classes bytecode in the current directory !

you can also tell java to search the current directory with the -classpath parameter

> java -classpath . Hello

Problems like this can really discourage java newbies, and that moment was very embarassing :)




Comments
Add New Search RSS
Thanks
Deepak (59.160.195.xxx) 2008-01-31 12:51:55

It was really helpful. Thanks a lot. 8)
java error
avesh (210.212.163.xxx) 2008-03-26 04:52:49

SET PATH=C:\j2sdk1.4.2_05\bin

SET CLASSPATH=C:\j2sdk1.4.2_05\bin

SET JAVA_HOME=C:\j2sdk1.4.2_05

To solve java runtime error type above codes
null
Anil (203.11.131.xxx) 2008-05-30 11:59:33

Thanks !
java error
rishi (125.16.130.xxx) 2008-07-04 08:49:50

in command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

best of luck for java programming.
Thanks a Lot
ZutoKido (200.84.135.xxx) 2008-08-03 19:16:44

It was really helpful! Thanks!!!
Error
Jessiecca (192.8.215.xxx) 2008-08-07 11:24:39

Thanks a lot... it was of great help
sandhya (61.17.44.xxx) 2008-08-27 11:54:14

:grin Thanks for this solution
aLumma (83.226.201.xxx) 2008-09-02 23:12:14

thanks a lot!

what is the "CLASSPATH" variable doing? does it have to read "SET" in front? it doesn't here, and i dont't have the "JAVA_HOME" variable either, should i put it in??

sorry if these questions are beyond stupid, but i'm totally new to java!

.a
Anna (83.139.18.xxx) 2008-09-30 13:44:13

Thanks a lot!!!!!!!!!!!! That was very helpfull.
varvar (130.212.3.xxx) 2008-10-02 08:18:38

Thanks a ton dude!
even i was stuck at this silly silly point

Thanks again
sek
SEKHAR (203.123.186.xxx) 2008-10-10 08:17:32

hi folks ,
thanks for u r useful comments.
but any one here tell me what's the difference between these 3 paths
1.JAVA_HOME
2.CLASSPATH
3.PATH
thanks (129.110.199.xxx) 2008-10-11 09:38:37

Thanks a lot!
Shamus (69.169.132.xxx) 2008-10-22 03:07:27

MUCHAS GRACIAS!
Error
Sneha (12.37.22.xxx) 2008-10-23 00:34:10

Thank you.. This is really helpfull for me a Newbe to java.
nisha (203.200.19.xxx) 2008-11-10 13:20:18

Thanx aloooooooot.........its been a great help
Reaper (147.32.221.xxx) 2008-11-10 16:32:18

finally it works, after searching thousands of sites on net, it solved this easy one. thx, thx, thx a lot
jdbc
jyothi (117.195.199.xxx) 2009-01-15 08:16:50

hi guys,
m unable to rectify the error even now after doing all alternative techniques.plz help me m gvng my program below:

import java.sql.*;
import java.io.*;
import java.util.*;
public class JDBCExample1{
public static void main(String args[]) throws Exception
{
FileInputStream fis=new FileInputStream("config.properties");
Properties props=new Properties();
props.load(fis);
String vdriver=props.getProperty("driver");
String vuname=props.getProperty("uname");
String vpwd=props.getProperty("pwd");
String vurl=props.getProperty("url");
Class.forName(vdriver);
Connection con=DriverManager.getConnection(vurl,vuname,vpwd);
System.out.println(con.getClass());
con.close();
}
}

config.properties

String driver=Oracle.jdbc.driver.OracleDriver
String uname=system
String pwd=tiger
String url = jdbc:oracle:thin:@localhost:1521:xe
Song Toan (141.228.250.xxx) 2009-01-21 09:00:54

I'm a new guy to Java using JDK 6 in Windows. I stuck here few hours for this issue. None of the solutions found from Internet solved. Finally, I got it worked.

There are 2 ways:

1) Set CLASSPATH environment to C:/Program Files/Java/jdk1.6.0_11/jre/lib;./;
Your jdk installation may be at different location.

2) Use -cp option:
java -cp "C:/Program Files/Java/jdk1.6.0_11/jre/lib;./;"

Pay attention at the "./" at the end of the paths in both solutions.

Conclusion: The java.exe does not take current directory by default! We have to add it into by ourselve!

Hope this save times of many many new guys like me!
got it
lokesh (117.197.208.xxx) 2009-01-30 17:46:22

thank s dude
Ramya NR (122.164.29.xxx) 2009-01-30 18:14:01

Thank u. This was a very useful solution for my long time struggle with the java s/w. Most don't know this logic. thanks again.
help please
ashiq (155.35.46.xxx) 2009-02-03 12:17:16

I am struck even i change the variables i am getting the same error
i am completely new to java can you help me
the error is:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
Thanks
Dang Tuan (210.245.54.xxx) 2009-02-13 02:30:08

I've tried the command: set classpath=%classpath%;.;

It works! Amazing :D

Thanks.
KK (88.224.243.xxx) 2009-03-26 14:47:55

set classpath=%classpath%;.;

it works thanks a lot
Shashank Sawant (70.185.117.xxx) 2009-05-25 08:23:09

I tried all the solution mentioned above but my problem still persists. Here is what I did in detail:
When I tried to compile my HelloWorldApp.java file using the following command:
javac HelloWorldApp.java
it worked (for being able to do this simple thing I had to change a lot of variables).

But then when I tried to Run the program using:
java HelloWorldApp
it gave me the error:
Exception in thread "main" java.lang.noclassdef...
...
...
...

To solve this error I tried various commands like:
set classpath=%classpath%;.;
java -classpath . HelloWorldApp
java -classpath . HelloWorldApp.class

but to no avail. Can anyone help me out with this problem?

Regards,

-sgsawant
Gajanan (198.22.122.xxx) 2009-09-03 23:58:46

Thanks so much I had same problem. Really stupid problem which can discourage you .
padmakar vishe (59.161.13.xxx) 2009-09-25 20:58:28

Thanks...a....lot... :)
dharmendra (117.199.145.xxx) 2009-10-03 12:48:51

many many thanks,
nano (71.67.102.xxx) 2009-10-07 09:42:40

the problem was the missing dot "."
without dot, I think the JVM does not feel like searching the current working directory for the class.
YES, this can surely discourage the JAVA newbies.
I insanely wasted 1 hour over this problem in uninstalling and reinstalling the JAVA SE.
GREAT TO SOLVE
FARAZ (118.103.231.xxx) 2009-10-16 10:04:03

I SOLVE THIS ERROR
HOW?
WAIT FOR MY NEXT COMMENT

FARAZ
Elridge D (130.164.78.xxx) 2009-10-30 20:28:36

I was seeing this error even though i had the correct environment variables (PATH and JAVA_HOME).

I found that the issue had to do with where I was compiling my test class. I had it in a package (com.xyz.apps.test.setup), so the fix for me was that I needed to run the javac command at the same level as where the /com directory existed. I had tried to compile it from the level of where the class lived (inside /com/xyz/apps/test/setup). Also, i specified a destination directory and then ran the java command on the compiled class in that directory.
Jack B (209.212.21.xxx) 2009-11-06 01:05:44

Thank you sooo much
hmmmmmmm (68.78.181.xxx) 2009-11-25 06:36:05

i still dont get where to put these.. i put the CLASSPATH=.;c:\programme\jboss\lib;c:\programme\
j2sdk1.4.2_08\lib;c:\programme\j2sdk1.4.2_08\jre\l ib; in the variable name but whats the value.. i vid tut would be nice if you could make me one thanks :)
Error
Abhi (115.108.2.xxx) 2009-11-26 22:31:18

Thanks a lot!!! :)
sms
sms (122.160.104.xxx) 2009-11-30 06:16:45

It was really helpful! Thanks!!!
sms
sms (122.160.104.xxx) 2009-12-01 08:58:14

Error
finally it works, after searching thousands of sites on net, it solved this easy one. thx, thx, thx a lot
Prasad (192.223.163.xxx) 2010-02-26 14:31:50

Just found out one more problem while setting up CLASSPATH
SET CLASSPATH=C:/Program Files;
and
SET CLASSPATH="C:/Program Files"; BEHAVES very differently while executing from command prompt but works fine if environment variable is set with out text qualifier ("") and IDE is used for execution
If there is space between (Like Program Files) use text qualifier “C:\Program Files\Cognos\c8\webapps\p2pd\WEB-INF\lib” for path instead of C:\Program Files\Cognos\c8\webapps\p2pd\WEB-INF\lib

Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
:D:):(:0:shock::confused:8):lol::x:P:oops::cry:
:evil::twisted::roll::wink::!::?::idea::arrow:
MathGuard security question, please solve:

S2U         W4G      
U 9    Q      I   N4Q
A87   XBI   9I7      
M W    D    5     BT5
5JA         LDN      
Please input the anti-spam code that you can read in the image.
 
Add URL of a programming website
register as a freelancer
submit your project
open freelance projects you can work on
webmaster resources
write for us tips, articles

Recommended: (advertise)
Advertise Here -
Promote your services and get the new customers from the community of webmasters / programmers visiting CodeGravity.com

Add URL of your website -
Submit your programming or software development website to webmaster resouces directory and share it with everyone.

Web hosting -
Rioserver Web Hosting provide ultra-reliable. We offer a range of packages which we believe are better than any other web host simply a cost-by-cost basis.

Outsource your project -
Submit your project description with all the requirements to more than 600 freelancers from around the world for FREE.

Register as a Freelancer -
Submit your project experiences, programming languages and your other skills


Download Joomlawatch 1.2.9

Download the NEW* JoomlaWatch 1.2.9 official from 20.04.2009 available for Joomla 1.5 and Joomla 1.0

RSS Feeds:new

rss Freelance
rss Projects
rss Forum
rss Resources

Popular:
MathGuard
download mathguard
Random screenshot:

linoopz15.jpg


Poll
I've installed JoomlaWatch 1.2.9 and:
 

News:

Registration required
I know that people don't like registering on websites, but I had to do it. From this moment you have to register first, before you download any file. This is better, because this way I can give you quick info about new version of downloadable files (eg. MathGuard) or some necessary security fixes. Thanks for understanding. (26.08.2007)

Books about investing and finance
I'd like to recommend you to read a book by Robert T. Kiyosaki - "Rich Dad, Poor Dad". However many people say it's quite a controversial book, it gave me a good motivation to improve my financial intelligence. (23.08.2007)

Fighting with the spam
All of the forms were protected with my own PHP antispam class - MathGuard, including the forms in the joomla modules I use. (02.05.2007)

Forum
Converted posts from the old punbb forum to the new joomlaboard (25.02.2007)

Improvement
Fixed some issues with the freelance registration, added a possibility to add a new programming resource, reorganized the structure of the programming resources. (24.02.2007)

New content management system
Codegravity.com is now running on joomla cms :) Added features like comments, forum etc. I hope you'll like it. Today I fixed the problem with the comment module which was not showing the correct images. There is also a new URL structure. For the old urls there is a 301 (Moved permanently) http redirect. (10.02.2007)

Moved to another hosting
Codegravity.com has been moved to another web hosting - CustomHosting.sk, from the previous pipni.cz, mainly because of the mod_rewrite problems and slow loading of the website. Sorry for some problems that lasted for about an hour. (19.01.2007)

Bookmark feed
The new feed from the del.icio.us has been added to the homepage codegravity.com. You 'll always have the latest information about the sites I like and you should visit as well! (21.11.2006)

News improved
Today I improved the news feeds. They are sorted into categories and I also added some other feeds that may be interested for you. (31.03.2006)

The Antispam verification
My email form was hijacked by the spam bots and I was recieving a lots of junk into my mailbox everyday. So, I decided to put a simple verification in the end of the form. You have to answer the result of addition of two numbers. Thank you for your understanding. (07.03.2006)

Java SE 6 Beta Mustang is out !
This beta release is a major milestone in the development of Mustang. It provides a complete stable snapshot of the final release functionality. http://mustang.dev.java.net (20.02.2006)

Google analytics, apply online
Apply online to google-analytics.com. They offer the new way of analysis of your website visitors. It is very promising, and when you will recieve the invitation code, you can send me one :) Thank you :) (13.02.2006)

Money Manager 2 - software for mobile accounting

FaceRSS - simple JavaServer Facer (JSF) component
I registered my new project - FaceRSS on freshmeat.net, here is the description: FaceRSS is a simple JavaServer Faces (JSF) component that allows you to display news from a specified URL source in one configurable JSP tag. This allows you to place news feeds on a Web site in a very simple way. It uses rsslib4j and therefore supports RSS version 0.9x, 1.0, and 2.0 with Dublin Core and Syndication namespaces. (06.01.2006)

My new blog :)
Check out my new [jroller.com/page/matto3c] blog on jroller.com website. Here is the RSS feed [http://jroller.com/rss/matto3c] if you'd like to add it into your news reader. (14.12.2005)

Optimizations
Thanks to the SEO company SeoVisions, for the basic optimization of this website. (11.12.2005)

ERM-II and Slovakia
SLOVAKIA, my home country, is now one step closer to adopting the common European currency - EURO. At midnight between November 25 and November 26, the country joined the Exchange Rate Mechanism 2 (ERM-II) (30.11.2005)

www.jground.com
I established a new website - http://www.jground.com, it's all based on JSF and it should be all about Java and all other related things. Enjoy! (25.11.2005)

Swing text antialiasing

Java webhosting
I'm trying a new http://www.move.cz java webhosting on www.move.cz, but it seems they don't respond to my questions about JSF ;( (16.11.2005)

Migration from Weblogic to JBoss
Currently I am working on a task: Migration of one J2EE application from Weblogic to JBoss application server. So, if you have any suggestions or resources, I would be glad if you'll send me some. Thanks (15.11.2005)

Increased Java performance
Java increased its performance on desktop by 58% : [http://www.javalobby.org/java/forums/t54006.html] Java Performance
Improvement (15.11.2005)

Exadel Studio Pro
At this time I'm playing with JSF (Java Server Faces). I want to recommend you a great IDE - Exadel JSF Studio Pro. It costs about $99, and there is 15 days trial available. You can also try MyEclipse which has also like Exadel - WYSIWYG editor for editing JSP, JSF pages. It can save you a lot of time. For more info, visit www.exadel.com (27.09.2005)

Programming directory
added a new programming resources directory, where you can submit your own programming website (14.09.2005)

Programming forum
Now the Programming forum is included in website design. I put there some topics from previous version of this forum. (19.08.2005)

Ubytovanie, podnajom Poprad
Ponuka na podnajom, ubytovanie: Zrekonštruované podkrovie - rodinny dom Poprad-Matejovce - 2 izby + pracovna + kúpelna s kuchynou, strešné a plastové okná, samostatné plynové kúrenie, drevené plávajúce podlahy, garáž, velká záhrada a samostatný vchod. . . Cena: dohodou
Kontakt: 0908 190 372 (18.02.2008)

Stavebny pozemok
Predám stavebný pozemok v prijemnom prostredí kúpelov Vyšné Ružbachy v blízkosti lyžiarskych vlekov. Inžinierske siete v blízkosti. Vhodný na relax ale aj podnikanie. 1767+27m2. 0908 190 372
Privacy policy | Advertise | Donate

Locations of visitors to this page


©2003-2009 Codegravity.com - Home