Solved

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

Posted on 2009-07-02
3
233 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mysql jsp example issue 32 48
CSV file parsing thru Java 13 34
running on tomcat not jboss eap 7.0 3 17
Java class and jar 3 20
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

808 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