Solved

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

Posted on 2009-07-02
3
230 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
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 250 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 59

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now