Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-07-02
3
Medium Priority
?
240 Views
Last Modified: 2012-05-07
Hi,

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.
0
Comment
Question by:techin4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 1000 total points
ID: 24766627
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
0
 

Author Comment

by:techin4
ID: 24766848
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.
Thanks!
But i have one more question.
I saw you that you posted javac -cp
What does that -cp for?
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 24766940
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 '.'.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question