![]() You can write it in any of your favorite text editors. The next step is to write your first Java program. ![]() Then move to that directory as follows: $ cd MyJavaDirectory I am creating such a directory through the following command in my home folder: $ mkdir MyJavaDirectory Your First Java Programīefore starting to write Java programs, it is best practice to make a dedicated directory for all your Java related work. The basic installations you need to have before running a Java program are now complete. ![]() You can then check the installed version of the Java Compiler as follows: Please enter Y to continue, after which JDK will be installed on your system. The system will prompt a Y/n option for you to continue installation. You can install it through the following command as root: $ sudo apt install default-jdk The above output shows that I need to install the Java compiler or the JDK on my system. This can be done by checking the version of your Java Compiler, javac, as follows: $ javac -version You can then check the installed version of Java as follows:Īfter installing the JRE, let us check if we have the Java Development Kit installed on our system or not. Please enter Y to continue, after which JRE will be installed on your system. In order to install the Java Runtime Environment on your system, run the following command as root: $ apt install default-jre In my case, the output shows that I do not have Java installed on my system yet. If yes, it will also let you know which version of Java you have on your system. This will ensure either Java Runtime Environment is already installed on your system or not. The next thing is to run the following command: $ java -version Since we will be installing Java through the apt utility, first let us update our apt repositories through the following command: $ sudo apt update You can open the Terminal either through the system Dash or the Ctrl+alt+T shortcut. Let us first open the Ubuntu command line, the Terminal, in order to install these two. In order to compile and run a basic Java program, you need to have the following two software installed on your Ubuntu system: We have run the commands and procedures mentioned in this article on an Ubuntu 18.04 LTS system. You will then compile your program in order to create a class that you can then execute in order to run your Java program. You can then write your first program in a text editor such as gedit, nano or even some graphical text writing tool. This article covers the installation of these two through the Ubuntu command line. The applications that you need for this purpose include the Java Runtime Environment and the Java Development Kit. If you are new to Java Programming in the Ubuntu operating system, this simple tutorial will guide you along in writing and compiling your first Java Hello World program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |