Compile Java Code from Console

I have learn how to create java code last week. I am use Eclipse to create the code and interesting how to compile java code manually from console. We can get some of help how to compile java code manually by typing in console :

Example, I have java code with name : We can compile this code to *.class with command :

We can define output example.class location with adding “-d” parameter. Example, I want to set location for the class output file at “bin” directory. So, modify the compile command with :

If our code not in the current active directory (example : source location in src directory), we can modify the command with :

Our code use some of external library (*.jar”) in “lib” directory. So, modify the program with command :

The output from above command is *.class file. We can convert java class to jar with command :

We can get more explanation related with java command console parameter from javac command. Using the above example, we can compile our java code without depend with our favorite editor (compile java from console).

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.