Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to compile

 
Elizabeth Jacob
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
my computer needed to be reinstalled and then i downloaded jdk1.2.2 .I saved the file Say.java in c:\java .when i try to compile i'm getting the following error:
error:can't read: Say.java
could it be something with setting the PATH and CLASSPATH ?
Any help will be appreciated.
Thanks,
Elizabeth.
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you currently have for your PATH and CLASSPATH settings?
 
Richard Boren
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error msg: error:can't read: Say.java when compiling is most likely caused because your PATH is not correct. You should check both the PATH and CLASSPATH and make sure they have the same dir names for your JDK1.2 and where you keep your source.
- error:can't read: SomeClass.java (is usually a PATH problem).
- Exception in thread "main" java.lang.NoClassDefFoundError: Someclass/java (is usually a CLASSPATH problem).
The above assumes you typed the class's name correctly to begin with.
Also it would help everyone if you would tell them what OS you are using.
Hope this helps
 
Elizabeth Jacob
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you.
i'm working on windows 95.i set the CLASSPATH as c:\java & did'nt know what to do with the PATH variable.could you pl tell me how to set those two variables thru the DOS prompt.
Thanks,
Elizabeth.
 
Richard Boren
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your autoexec.bat use:
SET PATH==%PATH%;C:\your_jdk_version;C:\your_jdk_version\bin;c:\where_your_java_sources_is
SET CLASSPATH=c:\where_your_java_sources_is\;.;
where your_jdk_version = what ever the directory name is for your jdk.
Note: I have found that if you use the default dir when installing the JDK for jdk1.1+ it makes life easier when dealing with the classpath because you only have to put where you keep you source and tell it to look in the local dir, that's the ;.; part. For example my path and classpath are as follows:
SET PATH=%PATH%;C:\jdk1.3;C:\jdk1.3\bin;D:\my_java
SET CLASSPATH=D:\My_Java\;.;
You can see your current setting by entering:
c:>set
This will show you all your current settings.
After you have updated your autexec.bat you will need to reboot for the new setting.
Good luck.
[This message has been edited by Richard Boren (edited June 05, 2001).]
 
Elizabeth Jacob
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Richard,i'll try that.

Elizabeth.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic