Javac doesn't produce a .class file

java

#1

I created a new blank workspace, created a HelloWorld.java file

public class HelloWorld {
    public static void main(String... args) {
        System.out.println("Hello, World!");
    }
}

And then I ran the following commands (followed by their output, except for the apt-get commands because they contain links).

1  sudo apt-get update
2  sudo apt-get install default-jdk
3  javac -version

javac 1.7.0_101

4  javac HelloWorld.java
5  ls

HelloWorld.java README.md

6  history

1 sudo apt-get update
2 sudo apt-get install default-jdk
3 javac -version
4 javac HelloWorld.java
5 ls
6 history


#2

Are you sure your code is correct? Try String[] args


#3

It’s a varargs format since 1.5.


#4

Interesting, and you get no compilation errors? And the String... args is also quite interesting.


#5

There’s no compilation errors and there’s no terminal output. I just tested on my Mac and this is consistent with a functional javac/environment, but there it actually produces the HelloWorld.class file that can be run with the java HelloWorld command.


#6

Did you save the file? no error and no class file usually means the file is empty. Check for grey dot on the tab close button or try cat HelloWorld.java.