473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

(Newbie Question) Javac Not Overwriting Properly

When I try to recompile code after making a change to it, my .class file doesn't change (as far as I can tell). Javac still finds errors in my code, but if I want to get a new class file I have to save my code under a different name. Even if I delete my current .class and .java file it still doesn't change. Any ideas, or things I could try to give you a better idea of the problem?
Nov 20 '08 #1
7 2220
Nepomuk
3,112 Expert 2GB
Are you sure you're in the right directory? I've had problems where I was compiling one set of code and trying to use another. Silly mistake, I know, but I guess it can happen to anyone.

Greetings,
Nepomuk
Nov 20 '08 #2
r035198x
13,262 8TB
If your code has errors then a .class file will not be created. Better get rid of the compilation errors first.
Nov 20 '08 #3
@Nepomuk: Thanks, but the directory is definitely not the problem

@r035: Yeah, see, I'm sure the problem is something obscure, because my code has no errors, but when I recompile the class file isn't replaced.

Thanks for trying, though. Maybe it'll work itself out in time.
Nov 20 '08 #4
r035198x
13,262 8TB
...
@r035: Yeah, see, I'm sure the problem is something obscure, because my code has no errors..
I thought you said that javac still finds errors in your code? (in your first post).

...
...
Thanks for trying, though. Maybe it'll work itself out in time.
It won't. computers don't work that way. If you are sure that your code doesn't have errors then move that .class file to some other directory so that there is no class file in the output directory. You can then run the javac command again and tell us the results.
Nov 20 '08 #5
My code had errors, I fixed them, and it still didn't overwrite, is what I was saying.

Alright, here's my exact movements:

Here's the code for Main.java:
Expand|Select|Wrap|Line Numbers
  1. import java.awt.Font;
  2. import java.awt.Graphics;
  3. import java.awt.Color;
  4.  
  5. public class Main extends java.applet.Applet {
  6.  
  7.     public void paint(Graphics g) {
  8.         setBackground(Color.blue);
  9.         g.setFont(new Font("sansserif", Font.BOLD, 12));
  10.         g.drawString("FONT TEST", 10, 10);
  11.     }
  12. }
  13.  
Created new folder (named "New Folder").

Moved Main.java into New Folder.

Open up command prompt.

Command prompt says: "C:\Documents and Settings\registered user".

Typed "cd Desktop/New Folder"

Typed "javac Main.java"

That generated no response, which is good, I think.

I checked and the class file was in New Folder. I then opened up the applet in a web page in New Folder, and everything worked out okay.

I then tried to recompile it, this time changing the Color.blue to Color.black. Nothing changed in the applet.

So what do you think? Should I try a reinstall of javac?
Nov 21 '08 #6
r035198x
13,262 8TB
Did you restart the applet?
Nov 21 '08 #7
chaarmann
785 Expert 512MB
If you have an applet in the browser, then the browser doesn't load the new class file if you change the applet. It uses the one loaded before from cache.
So it's not a problem with compilation, but with your browser settings.

You can do different things to force the browser to reload the changed applet:
1.) Try to press F5 in your browser.
2.) In InternetExplorer, Under internet options, menu extras--> internet options, tab common, button settings (where you can delete temporary files etc), there is a radio button that is usually "automatic", switch it to : load new versions of page ever every time you visit page.
3.) Put META tags inside your HTML-page to force the browser to refresh.
4.) If there is a proxy server between your browser and your server where your application is running, contact the network admin and tell him to configure your page not to be cached.
Nov 21 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Interzoner | last post by:
I am new at Java.. I installed j2sdk-1.4.2-nb-3.5-bin-windows on a Windows 2000 machine I can't find a "Javac"file......
4
by: Murat Tasan | last post by:
how well is javac from sun's jdk tools optimized? wow, that's a general question... so i guess here is a simple example... let's say i have a program that uses an array. and many times in the...
2
by: Samuel Jackson | last post by:
Hi, I'm wanting to figure out what version bytecode is generated with Jikes. I'm developing in an environment where it's mandated we run on Java 1.3. I'd like to run Jikes as my compiler (for...
1
by: Peter van der Goes | last post by:
Picked up a book that instructs beginners to use javac -source 1.5 <filename>.java to compile source code. I've observed that (with 1.5 the only installed SDK) javac <filename>.java ...
5
by: hawat.thufir | last post by:
I think the compile target is causing the errors...? from the terminal: $ cat build.xml <project name="tidy" default="package"> <import file="tidyBuild/properties.xml" /> <target...
19
by: tweak | last post by:
I have been messing around with buffers, and I found it peculiar that the code below will run without a segmentation fault. As far as I know, overwriting the allocated space from a call to...
3
Lokean
by: Lokean | last post by:
Sorry for this newbie question, this is not my realm of expertese. I have searched google, tried several applications that claim they can do this, such as Mapforce, which I found confusing, to...
3
by: Sean425 | last post by:
I've just started attempting to learn Java, but when I tried to compile my "Hello World" program I got an error. I'm hoping someone here can help me fix it, I imagine it won't be to difficult, a...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.