473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with "main" error


I am pretty new to Java and I just install the JDK1.4.2 03
I am getting an error when I run the class file TestChart.class with the
java.exe:

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

I have several class files in the directory d:\personal\java-ChartGen

Chart.class
ChartColourScheme.class
ChartPanel.class
ColorPanel.class
TestChart.class
TestIt.class

All these files are for the program.
Can some one help me why is this happening?? Is there something I can do
that I am missing???
I tried using the -CLASSPATH to direct it to the same directory but still
with the same error.

Please help me. Thank you

Jul 17 '05 #1
7 2745
news wrote:

I am pretty new to Java and I just install the JDK1.4.2 03
I am getting an error when I run the class file TestChart.class with the
java.exe:


What's your command line? What is the full error message? We can't
read your mind, or your screen; and withholding important information
like that makes it very difficult to answer your question.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 17 '05 #2
I use the command line as follows:

c:\j2sdk1.4.2_03\bin\java d:\personal\java-ChartGen\TestChart.class

The full error message is as follows:

Exception in thread "main" java.lang.NoClassDefFoundError:
d:\personal\java-ChartGen\TestChart/class
I thought it may be the CLASSPATH, but all my class files are located in the
same folder and I used the switch -classpath but the same error comes up.

"Chris Smith" <cd*****@twu.net> wrote in message
news:MP************************@news.pop4.net...
news wrote:

I am pretty new to Java and I just install the JDK1.4.2 03
I am getting an error when I run the class file TestChart.class with the
java.exe:


What's your command line? What is the full error message? We can't
read your mind, or your screen; and withholding important information
like that makes it very difficult to answer your question.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Jul 17 '05 #3

"news" <j@j.cm> wrote in message
news:uF*****************@nwrdny03.gnilink.net...
I use the command line as follows:

c:\j2sdk1.4.2_03\bin\java d:\personal\java-ChartGen\TestChart.class

The full error message is as follows:

Exception in thread "main" java.lang.NoClassDefFoundError:
d:\personal\java-ChartGen\TestChart/class

I thought it may be the CLASSPATH, but all my class files
are located in the same folder and I used the switch -classpath
but the same error comes up.


You shouldn't be using the '.class' extension on the command-line. The JVM
expects a classname, so you would be better off doing:

c:\j2sdk1.4.2_03\bin\java d:\personal\java-ChartGen\TestChart

Alternatively:

* Set your PATH [similar to setting the CLASSPATH as
I earlier described] to include the location of the J2SDK
binaries

set PATH=%path%;c:\j2sdk1.4.2_03\bin

* Now you can just change directory to the '.class'
file location:

d: <ENTER>
cd d:\personal\java-ChartGen\TestChart <ENTER>

* You may now invoke the application thus:

java -cp . TestChart

* Of course, if your application is 'packaged up', you may
need to do:

d: <ENTER>
cd \ <ENTER>

and invoke the application thus:

java personal.java-ChartGen.TestChart

I hope this helps.

Anthony Borla

P.S.

The following link may be of help:

http://mindprod.com/jgloss/classpath.html

Jul 17 '05 #4
On Sun, 14 Dec 2003 05:03:25 GMT, "Anthony Borla"
<aj*****@bigpond.com> wrote or quoted :
Exception in thread "main" java.lang.NoClassDefFoundError:


see http://mindprod.com/jgloss/errormess...SDEFFOUNDERROR

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Jul 17 '05 #5

"Roedy Green" <lo**********************************@mindprod.com > wrote in
message news:uq********************************@4ax.com...
On Sun, 14 Dec 2003 05:03:25 GMT, "Anthony Borla"
<aj*****@bigpond.com> wrote or quoted :
Exception in thread "main" java.lang.NoClassDefFoundError:


see http://mindprod.com/jgloss/errormess...SDEFFOUNDERROR


Well, I got the web site part right ;) !

Cheers,

Anthony Borla
Jul 17 '05 #6
In article <uF*****************@nwrdny03.gnilink.net>, "news" <j@j.cm>
wrote:
c:\j2sdk1.4.2_03\bin\java d:\personal\java-ChartGen\TestChart.class


When you use the java command, you don't specify ".class"--it is assumed
and the period makes java think its looking for a class inside of a
package, which you don't have.

You also don't have to specify full paths like that. (Maybe you're just
doing it in frustration at not getting it to work).

Just cd to the directory containing your classes and type

java TestChart

--
|\/| /| |2 |<
mehaase(at)sas(dot)upenn(dot)edu
Jul 17 '05 #7
news wrote:
I use the command line as follows:

c:\j2sdk1.4.2_03\bin\java d:\personal\java-ChartGen\TestChart.class

The full error message is as follows:

Exception in thread "main" java.lang.NoClassDefFoundError:
d:\personal\java-ChartGen\TestChart/class
I thought it may be the CLASSPATH, but all my class files are located in the
same folder and I used the switch -classpath but the same error comes up.


You've got a few responses, but I don't think they clearly explain the
issue, so I'll pop in. The Java VM expects a class name as it argument.
A class name is:

1. NOT a filename for a class file.
2. NOT the same as a filename minus the extension.

Instead of any of the above, it's a fully qualified class name. That
means the identifier that you put after the 'class' keyword in the
source file where you wrote the class, prefixed by the dot-delimited
string of identifiers after your 'package' keyword, if there is one.
Any "path" information shouldn't be there, period.

The source of confusion is that there are also a few rules that relate
the name of a class to how it's found by the VM. Those are incidental.
The classpath (set by an environment variable or command line option, or
various other implicit rules) determines at a basic level where the
class is found. The class name is the parameter, and it doesn't
duplicate the purpose of the classpath.

For this reason, I think it's helpful to say "use the class name, not a
file name" and that it's potentially quite confusing to say "leave off
the extension". After all, your command would still not have worked
even without the extension. Why? Because it's still not the class
name.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 17 '05 #8

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

Similar topics

0
by: Phillip Montgomery | last post by:
Hello all; I'm trying to debug an issue with a java script called, SelectSockets. It appears to be a fairly common one found on the web. I downloaded the SGI Java v1.4.1 installation from SGI's...
7
by: David Elliott | last post by:
I have created an application that will dynamically load other DLLs (plugins). The new plugin is a winform with an embedded IE Browser. I am wanting to have the form to run in its own thread....
6
by: Jofio | last post by:
I have a .h (header file) linked using #include<...>. I also have a .cp file which i don't know how to include in the header of my "main" file. I have the following c++ file. The file names are:...
1
by: kumarangopi | last post by:
Iam working with graphics.I wrote a pgogram in turbo c for graphics.I need to run on Freebsd system, so installed SDL and trying.when i give make in sdl_image folder /usr/lib/crt1.o undefined...
12
nomad
by: nomad | last post by:
Hi everyone; My Class has ended and I was not able to solve this problem in time, and I would still like to solve it. I got these error code. Exception in thread "main"...
3
by: Ananthu | last post by:
Hi This is my codings in order to access mysql database from java. Codings: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;
3
by: gator6688 | last post by:
import java.text.DecimalFormat; import javax.swing.JOptionPane; public class PayrollSystemTest { public static void main( String args ) { String workerType; String first;...
2
by: lilyumestar | last post by:
This project is due by Tuesday and I haven't even gotten half of it done. Can anyone please help me with this Exception error? I've been trying to figure it out for several hours Error Message ...
3
by: ohadr | last post by:
hi, i get Exception in thread "main" java.lang.NullPointerException when i run my application. the exact error is: "Exception in thread "main" java.lang.NullPointerException at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.