GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Why javac requires .java extension and java command does not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why javac requires .java extension and java command does not?" Watch "Why javac requires .java extension and java command does not?" New topic
Author

Why javac requires .java extension and java command does not?

Manu Somasekhar
Ranch Hand

Joined: May 22, 2012
Posts: 44
Hi,

I was wondering in order to run javac, i need to run the command as javac helloDark1.java


But to run the interpreter i need to run as "java helloDark1" not as "java helloDark1.class". Why that so?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
javac compiles the source file, hence it needs a Java file name. java command runs a Java class, and hence it needs a Java class name (not the .class file name).
Manu Somasekhar
Ranch Hand

Joined: May 22, 2012
Posts: 44
Hi John,

Thanks for your help.

As per this link:-


java documentation


"The java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method"
So the input of javac is the java file and the input of java is class which contains the main method.

Thank you .

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why javac requires .java extension and java command does not?