473,699 Members | 2,470 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

java.lang.NoCla ssDefFoundError

Lem
I get the error
Exception in thread "main" java.lang.NoCla ssDefFoundError

when I type java app2 in the command prompt. I've tried moving to the jre
directory and typed java c:\app2\app2, but it gives me the same exception.
What could be the problem?

Thanks in advance,
Lem
Jul 17 '05 #1
11 167106
Lem
There is nothing wrong with the code, it compiles fine, moreover the sdk
examples do not work as well.

Lem
Jul 17 '05 #2
In article <bg**********@n obel.pacific.ne t.sg>, Lem wrote:
There is nothing wrong with the code, it compiles fine, moreover the sdk
examples do not work as well.


If the SDK examples also don't work, then that seems to point back to a
CLASSPATH problem. To verify that this is the issue, you can try
invoking java using the cp switch to tell it explicitly where to find the class.
For example, if your app2.class is in a directory called c:\mydir, then
you could try

java -cp c:\mydir app2

(assuming the cp switch works the same in the Windows implementation -
I'm working from a linux box). If that works, then we at least know
that it's a classpath problem.

Mel Roman
me*@melroman.ne t
Jul 17 '05 #3
Lem
Thanks, the -cp switch worked, one thing I don't understand though, I ran my
app from its directory, shouldn't the jre start searching there first?

Thanks in advacnce,
Lem
"Mel Roman" <me*@melroman.n et> wrote in message
news:IO******** ***********@new s04.bloor.is.ne t.cable.rogers. com...
In article <bg**********@n obel.pacific.ne t.sg>, Lem wrote:
There is nothing wrong with the code, it compiles fine, moreover the sdk
examples do not work as well.

If the SDK examples also don't work, then that seems to point back to a
CLASSPATH problem. To verify that this is the issue, you can try
invoking java using the cp switch to tell it explicitly where to find the

class. For example, if your app2.class is in a directory called c:\mydir, then
you could try

java -cp c:\mydir app2

(assuming the cp switch works the same in the Windows implementation -
I'm working from a linux box). If that works, then we at least know
that it's a classpath problem.

Mel Roman
me*@melroman.ne t

Jul 17 '05 #4
In article <bg**********@n obel.pacific.ne t.sg>, Lem wrote:
Thanks, the -cp switch worked, one thing I don't understand though, I ran my
app from its directory, shouldn't the jre start searching there first?
--


At least this confirms that it's a classpath problem. As you say,
java should search the current directory (as well as those directories
specified in your CLASSPATH environment variable) to find your
app2.class file. Specifically, if your app2.class file is in your
c:\mydir directory, then you should be able to run app2 like this:

cd c:\mydir
java app2

You've already confirmed that you've tried this without success. I
can't explain why that isn't working for you. Perhaps one of our more
experienced brethren can offer an explanation.

At any rate, another poster recommended that you check and (if
necessary) modify your CLASSPATH. You'll probably want to define a file
hierarchy for storing all of your compiled *.class files (organized by
package) and put the top-level directory of that hierarchy in your CLASSPATH.
This link in the Sun tutorial talks about this:

http://java.sun.com/docs/books/tutor...gingfiles.html

Good luck,
Mel Roman
me*@melroman.ne t
Jul 17 '05 #5
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mel Roman wrote:

<snip>
cd c:\mydir
java app2

You've already confirmed that you've tried this without success. I
can't explain why that isn't working for you. Perhaps one of our
more experienced brethren can offer an explanation.

<snip>

Hi,
I have a pretty good idea of what the problem MIGHT be. The virtual
machine doesn't search in the current directory for class files,
unless the CLASSPATH variable is not set, or tells it to. That is, if
you must set CLASSPATH, set it so that the first item is . like this:

If your CLASSPATH needs to include "c:\mylib.j ar" for some reason, and
it is set like so:

SET CLASSPATH=c:\my lib.jar

replace it with this:

SET CLASSPATH=.;c:\ mylib.jar

On the other hand, if you don't need CLASSPATH, get rid of it and
everything should also be fine.

- --
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/JFI/wxczzJRavJYRAqT dAKCRr4fO/sk6my29ZV/HijfWHf47jQCg+W cF
du0UvkOHQImkzTf VWRbRAPk=
=AVqY
-----END PGP SIGNATURE-----
Jul 17 '05 #6
In article <Rw************ ********@news1. telusplanet.net >, Chris wrote:

I have a pretty good idea of what the problem MIGHT be. The virtual
machine doesn't search in the current directory for class files,
unless the CLASSPATH variable is not set, or tells it to. That is, if
you must set CLASSPATH, set it so that the first item is . like this:


Thanks for the input, Chris. I was playing with this a little while ago
myself. I didn't initially have any CLASSPATH variable, and executing
java myapp from within myapp's current directory worked just fine. Even
after setting my CLASSPATH to /home/mel/java, I can still always execute
an app from the current directory (outside of the CLASSPATH). Your
comments make me wonder if different java implementations behave differently.

Lem: Try doing what Chris says and see if that allows you to execute
"normally" (without the -cp switch) from the current directory. I'd be
interested in hearing your answer.

-

Mel Roman
me*@melroman.ne t
Jul 17 '05 #7
Lem
Thanks, it works =)

Lem
"Mel Roman" <me*@melroman.n et> wrote in message
news:98******** ***********@new s04.bloor.is.ne t.cable.rogers. com...
In article <Rw************ ********@news1. telusplanet.net >, Chris wrote:

I have a pretty good idea of what the problem MIGHT be. The virtual
machine doesn't search in the current directory for class files,
unless the CLASSPATH variable is not set, or tells it to. That is, if
you must set CLASSPATH, set it so that the first item is . like this:
Thanks for the input, Chris. I was playing with this a little while ago
myself. I didn't initially have any CLASSPATH variable, and executing
java myapp from within myapp's current directory worked just fine. Even
after setting my CLASSPATH to /home/mel/java, I can still always execute
an app from the current directory (outside of the CLASSPATH). Your
comments make me wonder if different java implementations behave

differently.
Lem: Try doing what Chris says and see if that allows you to execute
"normally" (without the -cp switch) from the current directory. I'd be
interested in hearing your answer.

-

Mel Roman
me*@melroman.ne t

Jul 17 '05 #8
On Sun, 27 Jul 2003 20:40:06 +0800, "Lem" <hj***@pacific. net.sg>
wrote:
I get the error
Exception in thread "main" java.lang.NoCla ssDefFoundError

when I type java app2 in the command prompt. I've tried moving to the jre
directory and typed java c:\app2\app2, but it gives me the same exception.
What could be the problem?

Thanks in advance,
Lem


You didn't say what environment, but your example above uses
DOS/Windows directory syntax. Sun's Java CL (if that's what you are
using) has Unix CL semantics ... try prefixing ".\" (current
directory) to the name of the class file you want to run, eg., "java
..\app2".

If that doesn't work, try using forward slashes "/" in the filespec.
There is (or use to be) an environment setting for the JRE that tells
it which to expect ... sorry, I don't remember what the setting is/was
- I only had to use it once long ago.

George

Jul 17 '05 #9
In article <3f************ ***********@new s.dial.pipex.co m>, Peter Bradley wrote:
Hi guys and gals,

I've never understood $CLASSPATH and packages and friends - but I had the
same problem, which is why I'm reading this thread.


I can't be sure, but I suspect that this Chris' comments may apply here
again. What is the value of your CLASSPATH variable? As Chris said,
clearing it may force java to look in your current directory.
--

Mel Roman
me*@melroman.ne t
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
9114
by: Andy Howells | last post by:
Can anybody help me on this? I am getting the below error but have not got a clue why. The file in my classpath eing used has the class that it says is not defined. Any ideas? I am running java version 1.4.0 and WMQ Series version 5.3 with CSD04. Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/mq/server/MQSESSION at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:67) at...
0
4497
by: Shawn | last post by:
I am getting the following error with a Java Applet being served out by IIS over HTTPS/SSL using a Verisign certificate: java.lang.NoClassDefFoundError: javax/help/HelpSetException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590) at java.lang.Class.getConstructor0(Class.java:1762) at java.lang.Class.newInstance0(Class.java:276) at...
3
6530
by: NathanK | last post by:
Hi Guys, im starting out in java and i'm getting the error: Exception in thread "main" java.lang.NoClassDefFoundError: blurf if i run "javac blurf.java", it compiles fine and without any troubles. when i try to run it (its a simple hello world program) i get the above error.
1
47609
by: greg.knaddison | last post by:
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on java1.4.2_04 (JIT: null) My Java version is:
0
3706
by: HiteshMehra | last post by:
Hi all, I am getting an error while trying to connect to the MQ. The error is java.lang.NoClassDefFoundError: com/ibm/mq/server/MQSESSION at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:68) at com.ibm.mq.MQSESSION.getSession(MQSESSION.java:493) at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:155) at...
4
14721
by: jmitch89 | last post by:
I don't why I get this error: Exception in thread "main" java.lang.NoClassDefFoundError The statement below works just fine: java -cp "appframework-1.0.3.jar;swing-worker-1.1.jar";CurrentStrobe.jar com.visionpro.currentstrobe.CurrentStrobeApp However, the statement below produces the error: java -cp "appframework-1.0.3.jar;swing-worker-1.1.jar" -jar CurrentStrobe.jar Exception in thread "main"...
4
5111
by: xtremebass | last post by:
Hi Bytes, i run the sample java code(BarChartDemo.java)which is producing the Bar charts as output if no error in the program, but i got run time error like this, java.lang.NoClassDefFoundError: BarChartDemo (wrong name: org/jfree/chart/demo/BarChartDemo) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at...
1
10081
by: rajujrk | last post by:
Hai All, I am Having a problem in the following... import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.io.FileUtils; import java.io.IOException;
1
3493
by: James Kalmadge | last post by:
I have a test program that compiles but does not run. Here is the code which I grabbed from from a web site: import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.sql.*; public class ColumnName{
0
8705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7785
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5884
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4391
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3075
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.