Link to home
Start Free TrialLog in
Avatar of yllee
yllee

asked on

can't find class name/class

I know there is a question with same subject but the solution
doesn't work in my case.

I have jdk ver 1.1.6 and installed in PC with Win98 2nd edition.
I able to compile source file to name.java.  But,
java name.java, always give this error message : can't find
class name/class.

Pls help me solve this problem.
Avatar of heyhey_
heyhey_

javac myClass.java
will create myClass.class

SET CLASSPATH=.;%CLASSPATH%
java myClass

will execute that class
hi,
  While compiling you have to give
javac name.java,
   and while running the program you have to give
java name,
   not java name.java.
The other thing is,in the name.java program suppose you have a class with different name like this:

name.java
class hello
{
public static void main(String []args)
{
System.out.println("hello");
}
}
  In this case compile the program with
javac name.java which will create hello.class.And if u want to run the program give java hello,it will work out.
   But the above case wont work if i am declaring the class hello as public since public class should be decalared in the file which should contain the same name.And ensure that CLASSPATH is set or not.
Avatar of yllee

ASKER

Sorry,

there is a typing mistake, it should be java name.class & the error message is : can't find class name/class.

In fact, I'm in Java programming.  I simply follow the example in the book.  So, I'm not really understanding your answer.

Here, below is one of the sample :

class Root {
         public static void main(String[] arguments) {
                 int number = 225;
                 System.out.println("The square root of "
                         + number
                         + " is "
                         + Math.sqrt(number) );
         }
}

I save it as test.java.  After javac test.java, root.class created.
According the book, output is : The square root of 225 is 15.0.
But, error message of java root : can't find class root ; error message of java root.class : can't find class root/class.

Here is my autoexec.bat for your reference :

C:\SBCD\DRV\MSCDEX.EXE /D:MSCD001 /V /M:8
SET BLASTER=A220 I5 D1 H5 P330  T6
SET CTSYN=C:\WINDOWS
C:\PROGRA~1\CREATIVE\SBLIVE\DOSDRV\SBEINIT.COM
C:\TVLITE\chgport 2DC

PATH C:\jdk11\bin;
set CLASSPATH=.;%CLASSPATH%;

rem PATH c:\PAGEMGR\IMGFOLIO;C:\PAGEMGR;C:\PROGRA~1\ULTRAEDT;%PATH%

Please let me know where goes wrong?

Thank you very very much.
ASKER CERTIFIED SOLUTION
Avatar of g_senthilkumar
g_senthilkumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial