Javac won't compile, can it cache an old file?

Windows 7 x64

Bad description of the problem I know, but it's very difficult to explain.

Basically I was trying to make some changes to an old program in IntelliJ after recently reformatting Windows and reinstalling java and all that jazz. No matter what I changed in the program, the result didn't change. It doesn't matter what I have commented or changed.

So, after some frustration, I decided to do some basic testing to make sure I wasn't just going crazy. I created a completely new directory. And in that directory, I made one file (using Sublime Text, not IntelliJ). Your classic Hello World program.

public class FrequencyCounter {
    public static void main(String args[]) {
        System.out.println("Hello World");
    }
}

      

It was the only file in the directory. Ran

javac FrequencyCounter.java

      

It is believed to compile perfectly, no errors are generated by the FrequencyCounter.class file in the directory. Ran

java FrequencyCounter

      

And got this error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at FrequencyCounter.main(FrequencyCounter.java:50)

      

Obviously it doesn't make any sense. It looks like it doesn't run the FrequencyCounter class in that directory, but some older ones cache elsewhere. Just for common sense, I copied the file, but changed it to HelloWorld.java

and public class HelloWorld { ..... }

, which compiles and works fine (in the same directory).

If it helps:

D:\Copy\Code\Learning\CS\IntelliJ\test>java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

D:\Copy\Code\Learning\CS\IntelliJ\test>javac -version
javac 1.7.0_07

      

+3


source to share


1 answer


Assuming you're telling us correctly, it launches the FrequencyCounter class from elsewhere. Most likely your classpath is set to a directory or jar that already has a FrequencyCounter class and it runs that.



+2


source







All Articles