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.
ylleeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

heyhey_Commented:
javac myClass.java
will create myClass.class

SET CLASSPATH=.;%CLASSPATH%
java myClass

will execute that class
0
g_senthilkumarCommented:
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.
0
ylleeAuthor Commented:
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.
0
g_senthilkumarCommented:
hi
  better give,
   set CLASSPATH=.;c:\jdk1.1.6\lib\classes.zip;
   in the autoexec.bat file and save it and run the autoexec.bat file.
  And check whether the .class file is available in the same directory which you working currently.
   Now try
    java root
   Still it is not working,then try
java -classpath c:\temp root
  assume that you are working temp directory which contains the root.class file.Now it will work.The option
-classpath allows us to specify where to find class for JVM.
   I think this will work out.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.