Why does my old .class file keep getting regenerated in java?


I am new to JAVA and I'm having some difficulties running my program.
I created a new file called Hello.java and saved it on my desktop.
I then typed the command javac.Hello from the command prompt.
The problem i'm having is that its suppose to compile a Hello.class for me
but instead it comiles a previous file which was HelloApp.class

Does anyone know why this happens?
I've installed the jdk6 and added the path to my bin directory.
Thank You.
Who is Participating?
Kevin CrossConnect With a Mentor Chief Technology OfficerCommented:
How are you compiling?

+double check that Hello.java has class in it defined as Hello instead of HelloApp
+copy the file into folder like c:\temp
+at command prompt do the following:

c:> cd \temp
c:\temp> javac -cp . Hello.java
techin4Author Commented:
Hi mwvisa1,

Your absolutely right.
I had HelloApp as the name of the class.
After renaming it to Hello, it compiled a Hello.class for me.
But i have one more question.
I saw you that you posted javac -cp
What does that -cp for?
Kevin CrossChief Technology OfficerCommented:
It is shorthand for -classpath which tells java where to find user class files during compilation which is good if you had other classes in your application in the same directory denoted by the '.'.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.