Results 1 to 12 of 12
  1. #1
    kprime is offline Member
    Join Date
    Feb 2013
    Posts
    15
    Rep Power
    0

    Default Source code won't recompile

    Hi,

    I'm having an issue with a particular Java program I'm writing. For some reason if I make changes and recompile, the changes are not reflected in my program. I have to delete the class files and then when I recompile new class files are created with the correct changes.

    I've been working on this program for some time and this is the first instance of this problem. May I get some advice on what the problem could be?

    Thank you.
    Last edited by kprime; 03-13-2013 at 07:26 AM.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,348
    Blog Entries
    7
    Rep Power
    20

    Default Re: Source code won't recompile

    I don't think your question can be answered without knowing the details; are you using an IDE? any version control system? Did you check the creation time stamp of your .class file(s) after recompilation?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default Re: Source code won't recompile

    Maybe your changes never get executed. Can you post your code so that we can see what the problem could be? You can also debug your code, check every step of your program to find out where it is not working as expected.

  4. #4
    kprime is offline Member
    Join Date
    Feb 2013
    Posts
    15
    Rep Power
    0

    Default Re: Source code won't recompile

    Hi,

    Thank you for your responses.

    I am not using an IDE. I just started learning Java recently. I am using the command prompt to compile and run my code. I don't believe I have any other settings than the default. When I compile for the first time the class files are created. When I try to recompile the class files aren't modified (the timestamps are the same as from the first compilation). I have to delete the class files in order to create new class files and have my changes reflected in my program.

    I've written a few programs and never had this problem before, even the program that is causing the problem now was fine earlier today.

    I'd prefer not to post my code as it is part of an assignment I'm doing for school.

    If I need to clarify any further to help resolve this issue, please let me know. Thank you.

    *EDIT*
    I'd like to add some more information. After the first compilation, subsequent attempts at recompiling seem to fail. I could delete all my code and running javac Program.java will not give me any compilation errors. It's as if the compiler is working with old code. Also I am using notepad++ to write my code if that's of any importance.
    Thank you again.
    Last edited by kprime; 03-13-2013 at 08:20 AM.

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,348
    Blog Entries
    7
    Rep Power
    20

    Default Re: Source code won't recompile

    Something is trying to be clever behind the scenes. Did you try using the command line only? i.e. "javac YourFile.java"

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    kprime is offline Member
    Join Date
    Feb 2013
    Posts
    15
    Rep Power
    0

    Default Re: Source code won't recompile

    Hi JosAH,

    I'm sorry but I'm not quite sure what you mean. I've always only compiled from the command line using javac ProgramName.java. But this is the first time I've had this problem. A few days ago this program was compiling fine as well.

    One thing is that I did have different versions of the code under the same class names. But they were all in different folders and I have since removed them.

  7. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,348
    Blog Entries
    7
    Rep Power
    20

    Default Re: Source code won't recompile

    I still can't adequately answer your question; did you save the new version of your source file before compiling? Check the time stamp of your .java file and make sure you're compiling what you think you are compiling (i.e. no other version of the source file is somewhere around).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    kprime is offline Member
    Join Date
    Feb 2013
    Posts
    15
    Rep Power
    0

    Default Re: Source code won't recompile

    HI JosAH,

    Yes I did save before compiling.
    I'm pretty sure that I'm not doing anything wrong as far as saving my code and compiling the correct code.
    The files are in a folder of their own.
    I can recompile but only if I delete my class files first. When I delete the class files and recompile, new class files are generated with the changes I made to my code.

    Btw thank you for your help.

  9. #9
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,809
    Rep Power
    19

    Default Re: Source code won't recompile

    Try:
    javac -cp . <yourfile>.java
    (That assumes your file is not in a package, you'll need to modify it otherwise to reflect that)

    If that works then you have a CLASSPATH declared in your environment variables that's mucking things up.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    kprime is offline Member
    Join Date
    Feb 2013
    Posts
    15
    Rep Power
    0

    Default Re: Source code won't recompile

    Hi Tolls,

    Thank you for the suggestion. I've tried what you suggested but I still have the same problem.

    I do have older versions of my code in other folders and they don't have this problem. Could this be caused by something I might have added in my code?

    Thank you.

  11. #11
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,348
    Blog Entries
    7
    Rep Power
    20

    Default Re: Source code won't recompile

    Try an experiment: rename your latest version of the source (i.e. the class name and the file name); compile that new version and recompile it (after making a futile change to the code); does that work?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  12. #12
    kprime is offline Member
    Join Date
    Feb 2013
    Posts
    15
    Rep Power
    0

    Default Re: Source code won't recompile

    HI JosAH,

    I have tried that and the problem persists. I have posted asking for help on another website. I read that cross posting on different forums on this site is not allowed, but if cross posting on different websites is, I'd like to post my latest findings here as well since I haven't found a solution yet.

    Thank you.
    Last edited by kprime; 03-13-2013 at 06:39 PM.

Similar Threads

  1. Replies: 3
    Last Post: 02-19-2013, 09:23 AM
  2. Replies: 2
    Last Post: 02-18-2013, 08:25 PM
  3. Replies: 16
    Last Post: 01-31-2012, 08:36 PM
  4. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  5. Replies: 1
    Last Post: 11-28-2008, 06:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •