By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,557 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,557 IT Pros & Developers. It's quick & easy.

error, can't find class java4cpp/basic/FirstProgram

P: n/a
I've installed JDK1.1.5 on my windows 2000 professional system and
when I give it the command ( in a command prompt window) to compile,
it does, but when I try to run the program I get this message:

---------------------------------------------------------------------------------------
C:\java4cpp\basic>java java4cpp.basic.FirstProgram
Can't find class java4cpp/basic/FirstProgram
---------------------------------------------------------------------------------------
The book suggested that I set the classpath, so I tried that with this
command: "set classpath=%classpath%;C:\java4cpp\bin" , which is the
directory on my harddrive that the files are installed to.
The program name is called FirstProgram.java and the
FirstProgram.class are both in the same directory
any help would be appreciated, this is all new to me.
Please forgive my lack of knowledge in the art of java programming.
This is my first encounter.

Thanks in advance, Mark.

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Don't forget to include "." in your classpath declaration which says
"look in the current directory for classes".

So your "set classpath" statement would read:
set classpath=%classpath%;.;C:\java4cpp\bin;c:\

You can also set the classpath at runtime if you wish:
java -classpath "%classpath%;.;C:\java4cpp\bin;c:\"
java4cpp.basic.FirstProgram

Notice that I've set the "C:\" directory in your classpath as well
since it looks like that's where your placed your package.

Hope that makes sense.

-Rich
Mark R Rivet <ma********@verizon.net> wrote in message news:<0d********************************@4ax.com>. ..
I've installed JDK1.1.5 on my windows 2000 professional system and
when I give it the command ( in a command prompt window) to compile,
it does, but when I try to run the program I get this message:

---------------------------------------------------------------------------------------
C:\java4cpp\basic>java java4cpp.basic.FirstProgram
Can't find class java4cpp/basic/FirstProgram
---------------------------------------------------------------------------------------
The book suggested that I set the classpath, so I tried that with this
command: "set classpath=%classpath%;C:\java4cpp\bin" , which is the
directory on my harddrive that the files are installed to.
The program name is called FirstProgram.java and the
FirstProgram.class are both in the same directory
any help would be appreciated, this is all new to me.
Please forgive my lack of knowledge in the art of java programming.
This is my first encounter.

Thanks in advance, Mark.

Jul 17 '05 #2

P: n/a
On 27 May 2004 09:39:00 -0700, ri*****************@yahoo.com (Richard
Anderson) wrote:
Don't forget to include "." in your classpath declaration which says
"look in the current directory for classes".

So your "set classpath" statement would read:
set classpath=%classpath%;.;C:\java4cpp\bin;c:\

You can also set the classpath at runtime if you wish:
java -classpath "%classpath%;.;C:\java4cpp\bin;c:\"
java4cpp.basic.FirstProgram

Notice that I've set the "C:\" directory in your classpath as well
since it looks like that's where your placed your package.

Hope that makes sense.
Hi Rich, and thanks for that info. It does make sense and I've taken
your advice. The book didn't really say it like that or I just didn't
get. Anyway that worked just fine and I thank you again. Now I can
proceed with working through the programming examples.
-Rich
Mark R Rivet <ma********@verizon.net> wrote in message news:<0d********************************@4ax.com>. ..
I've installed JDK1.1.5 on my windows 2000 professional system and
when I give it the command ( in a command prompt window) to compile,
it does, but when I try to run the program I get this message:

---------------------------------------------------------------------------------------
C:\java4cpp\basic>java java4cpp.basic.FirstProgram
Can't find class java4cpp/basic/FirstProgram
---------------------------------------------------------------------------------------
The book suggested that I set the classpath, so I tried that with this
command: "set classpath=%classpath%;C:\java4cpp\bin" , which is the
directory on my harddrive that the files are installed to.
The program name is called FirstProgram.java and the
FirstProgram.class are both in the same directory
any help would be appreciated, this is all new to me.
Please forgive my lack of knowledge in the art of java programming.
This is my first encounter.

Thanks in advance, Mark.


Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.