Compile a .java file on Linux

To compile a .java file on Linux (e.g., Ubuntu), first you need to install Java JDK on your computer. You can install it with the instructions at How do I install Java? , here and here.

Once you have java JDK installed, open your terminal and cd to the direcotry where your .java file located and type the following:

$ javac

To run the generated class file, use the following command

$ java filename



Leave a Reply

Your email address will not be published. Required fields are marked *