{"id":3096,"date":"2024-06-30T10:00:03","date_gmt":"2024-06-30T10:00:03","guid":{"rendered":"https:\/\/draculaservers.com\/tutorials\/?p=3096"},"modified":"2024-06-30T17:12:17","modified_gmt":"2024-06-30T17:12:17","slug":"run-java-programs-linux-terminal","status":"publish","type":"post","link":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/","title":{"rendered":"How to Run Java Programs in Linux Terminal?"},"content":{"rendered":"<p>Running Java or Java Programs within a Linux Terminal can be daunting. But worry not, as we have got you covered.<\/p>\n<p>Java is a popular programming language used to build all types of applications. With its object-oriented approach and easy-to-understand syntax, Java is considered one of the best programming languages to start with and grow with. It is supported by Linux, macOS, and Windows.<\/p>\n<p>However, most Linux users prefer to do things on the terminal, and running Java Programs on the terminal is no exception. This guide will demonstrate the steps to set up a Java environment on Linux so you can easily compile and run Java Programs on the terminal without any complications.<\/p>\n\n<h2 id=\"how-to-run-java-programs-in-linux-terminal\">How to Run Java Programs in Linux Terminal?<\/h2>\n<p><strong>To run Java Programs within the Terminal, you must ensure that the JDK has been installed on your machine. After that, the present working directory of the Terminal should contain the Java program you are trying to run. Lastly, you must use the \u201cjava filename\u201d command in the terminal<\/strong><\/p>\n<p>However, the Java program must be compiled using the <strong>Java Compiler Command<\/strong> (<strong>javac<\/strong>) before being executed through the terminal.<\/p>\n<p>Let\u2019s go over the step-by-step procedure.<\/p>\n<h3 id=\"verify-the-jdk-installation\">Verify the JDK Installation<\/h3>\n<p>Linux cannot compile or execute Java programs without the <strong>Java Development Kit<\/strong>. Therefore, the first step is to ensure the JDK has been installed on your machine. To verify this, open up a terminal (<strong>CTRL + ALT + T<\/strong>) and type in the following command inside it:<\/p>\n<pre>javac -version<\/pre>\n<p>Running this command will show you the current version of the installed JDK on your machine. But, if the command returns an error like the following.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3097\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1.png\" alt=\"\" width=\"1054\" height=\"386\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1.png 1054w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-300x110.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-1024x375.png 1024w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-768x281.png 768w\" sizes=\"auto, (max-width: 1054px) 100vw, 1054px\" \/><\/a><\/p>\n<p>This output means that the JDK is not installed on your Linux machine, and you must install it first.<\/p>\n<h3 id=\"install-jdk-in-linux\">Install JDK in Linux<\/h3>\n<p>To install the JDK on Linux, open a new terminal and type the following command.<\/p>\n<pre>sudo apt update<\/pre>\n<p>This command will apt repositories of your Linux. Once that is done, run the following command to download and install JDK from the apt repository.<\/p>\n<pre>sudo apt install default-jdk<\/pre>\n<p>Once you execute the command, the terminal will prompt you to provide the password for the root (sudo) user. Therefore, type that in and press the Enter key.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3098\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2.png\" alt=\"\" width=\"858\" height=\"190\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2.png 858w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2-300x66.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2-768x170.png 768w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/a><\/p>\n<p>After that, you will get a confirmation prompt on the terminal. Type \u201c<strong>Y<\/strong>\u201d and press the <strong>Enter <\/strong>key.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3099\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3.png\" alt=\"\" width=\"854\" height=\"522\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3.png 854w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3-300x183.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3-768x469.png 768w\" sizes=\"auto, (max-width: 854px) 100vw, 854px\" \/><\/a><\/p>\n<p>After that, wait for the downloading and installation process to complete fully. Once the installation is done, you need to verify the correct installation of JDK. To do this, open up a new terminal and type the following command.<\/p>\n<pre>javac -version<\/pre>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3100\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4.png\" alt=\"\" width=\"855\" height=\"233\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4.png 855w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4-300x82.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4-768x209.png 768w\" sizes=\"auto, (max-width: 855px) 100vw, 855px\" \/><\/a><\/p>\n<p>The output shows that the JDK has been successfully installed.<\/p>\n<h3 id=\"write-a-java-code-file\">Write a Java Code File<\/h3>\n<p>You need a code file written in Java that can be compiled and then executed on the terminal as a Java Program. If you do not have a Java file, then simply create one. Let\u2019s create a file named \u201c<strong>demo.java<\/strong>\u201d on the desktop using the command \u201c<strong>touch demo.java<\/strong>.\u201d<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3101\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5.png\" alt=\"\" width=\"617\" height=\"352\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5.png 617w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5-300x171.png 300w\" sizes=\"auto, (max-width: 617px) 100vw, 617px\" \/><\/a><\/p>\n<p>This file contains a basic Java code that prints \u201c<strong>Hello World<\/strong>\u201d on the console.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3102\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6.png\" alt=\"\" width=\"952\" height=\"252\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6.png 952w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6-300x79.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6-768x203.png 768w\" sizes=\"auto, (max-width: 952px) 100vw, 952px\" \/><\/a><\/p>\n<p>Once you have written the code inside the file, press the save button on the top right before exiting the file. Additionally, ensure that the class name is the same as the file name you created.<\/p>\n<h3 id=\"compile-the-java-program-using-the-javac-command\">Compile the Java Program Using the \u201cjavac\u201d Command<\/h3>\n<p>The next step is to compile the program using the Java compiler command. To do this, open a new terminal session and head over to the directory that contains the Java Program, Which is the desktop for this tutorial, and type \u201c<strong>ls<\/strong>\u201d to check for the file.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3103\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7.png\" alt=\"\" width=\"815\" height=\"149\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7.png 815w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7-300x55.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7-768x140.png 768w\" sizes=\"auto, (max-width: 815px) 100vw, 815px\" \/><\/a><\/p>\n<p>After that, use the following command template: \u201c<strong>javac filename.java<\/strong>.\u201d Which, in this case, will become \u201c<strong>javac demo.java<\/strong>.\u201d Doing this will create a new file in the same directory as \u201c<strong>demo.class\u201d<\/strong>.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3104\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8.png\" alt=\"\" width=\"418\" height=\"313\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8.png 418w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8-300x225.png 300w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/a><\/p>\n<h3 id=\"run-the-java-program-using-the-java-command\">Run the Java Program Using the \u201cjava\u201d Command<\/h3>\n<p>Once you have the Java Program, you only need the \u201c<strong>java filename<\/strong>\u201d command to run it through the terminal. Therefore, open a terminal, navigate to the directory of the Java Program, and then run the following command:<\/p>\n<pre>java demo<\/pre>\n<p>Running this command will generate the following output on the terminal:<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3105\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9.png\" alt=\"\" width=\"808\" height=\"162\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9.png 808w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9-300x60.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9-768x154.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/a><\/p>\n<p>The output shows that the Java Program was successfully executed through a Linux Terminal. However, remember that you don\u2019t have to add the \u201c.class\u201d part of the file while running the Java Program.<\/p>\n<div class=\"cl-preview-section\">\n<h2 id=\"affordable-vps-hosting-with-dracula-servers\"><span style=\"color: #ff2600;\">Affordable VPS Hosting With Dracula Servers<\/span><\/h2>\n<\/div>\n<div class=\"cl-preview-section\">\n<p>Looking for reliable and budget-friendly Virtual Private Server (VPS) hosting? Look no further than\u00a0<a href=\"https:\/\/draculaservers.com\/\">Dracula Servers<\/a>. Dracula Servers offers a range of VPS hosting plans tailored to meet diverse needs. With competitive pricing, robust performance, and a user-friendly interface, it\u2019s an excellent choice for individuals and businesses alike.<\/p>\n<\/div>\n<div class=\"cl-preview-section\">\n<p>Explore the\u00a0<a href=\"https:\/\/draculaservers.com\/\">Dracula Servers website<\/a> to discover hosting solutions that align with your requirements and take your online presence to new heights with their affordable and efficient VPS hosting services.<\/p>\n<\/div>\n<div class=\"cl-preview-section\">\n<p><a href=\"https:\/\/draculaservers.com\/\"><strong>Visit Dracula Servers<\/strong><\/a>\u00a0and experience reliable VPS hosting without breaking the bank.<\/p>\n<\/div>\n<h2 id=\"how-to-install-jdk-on-different-linux-versions\">How to Install JDK On Different Linux Versions?<\/h2>\n<p>The commands to install an application can vary with the version\/flavor of Linux you are running, which is also true when you want to install JDK on your Linux machine. However, the steps are the same: Update the Linux and run the respective installation command.<\/p>\n<p><strong>To install JDK on Ubuntu<\/strong>, run the following commands.<\/p>\n<pre>sudo apt-get update\r\nsudo apt-get install default-jdk<\/pre>\n<p><strong>To install JDK on Fedora<\/strong>, run the following commands.<\/p>\n<pre>sudo dnf update\r\nsudo dnf install java-11-openjdk-devel<\/pre>\n<p><strong>To install JDK on CentOS<\/strong>, run the following commands.<\/p>\n<pre>sudo yum update\r\nsudo yum install java-11-openjdk-devel<\/pre>\n<p><strong>To install JDK on Arch Linux<\/strong>, run the following commands.<\/p>\n<pre>sudo pacman -Syu\r\nsudo pacman -S jdk-openjdk<\/pre>\n<p>Once the installation is done, you can verify it using the command \u201c<strong>java -version<\/strong>.\u201d<\/p>\n<h2 id=\"how-to-run-jar-file-in-linux-terminal\">How to Run JAR File in Linux Terminal?<\/h2>\n<p>To run a JAR program on Linux through a terminal, make sure that you have JDK\/JRE installed on your Linux machine and the path variables are configured. Once that is done, open a terminal and head to the directory of the JAR file. Then run the command \u201c<strong>java -jar [filename].jar<\/strong>\u201d<\/p>\n<p>The main difference in running Java Programs and Java Applications (JAR files) is adding the \u201c<strong>-jar<\/strong>\u201d flag. However, if the class is not specified within the Java application&#8217;s Manifest file, you must use the \u201c<strong>-cp<\/strong>\u201d instead of the \u201c<strong>-jar<\/strong>\u201d flag and specify the entry class in the command.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>Running a Java Program through a terminal is a rather simple process. However, if you are doing it for the first time, then it requires you to perform a series of steps. These steps include ensuring the installation of JDK in your Linux machine, compiling the Java code into a Java Program, and then running the Java Program through the terminal.<\/p>\n<p>If you are only looking for the commands to run the program in the terminal, then use \u201c<strong>javac [filename].java<\/strong>\u201d to compile a java code into an executable program and the \u201c<strong>java [filename]<\/strong>\u201d to execute the program on the terminal.<\/p>\n<p>Check out More Linux Tutorials <a href=\"https:\/\/draculaservers.com\/tutorials\/\" target=\"_blank\" rel=\"noopener\">Here!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Running Java or Java Programs within a Linux Terminal can be daunting. But worry not, as we have got you covered. Java is a popular programming language used to build all types of applications. With its object-oriented approach and easy-to-understand syntax, Java is considered one of the best programming languages to start with and grow [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":3107,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[172],"tags":[451,452,453,102,122],"class_list":["post-3096","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-tutorials","tag-java","tag-java-coding-on-linux","tag-java-on-linux-terminal","tag-linux","tag-linux-guides"],"blocksy_meta":[],"featured_image_urls_v2":{"full":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png",1280,720,false],"thumbnail":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1-150x150.png",150,150,true],"medium":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1-300x169.png",300,169,true],"medium_large":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1-768x432.png",768,432,true],"large":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1-1024x576.png",1024,576,true],"1536x1536":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png",1280,720,false],"2048x2048":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png",1280,720,false],"pk-small":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1-80x80.png",80,80,true],"pk-thumbnail":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1-300x225.png",300,225,true]},"post_excerpt_stackable_v2":"<p>Running Java or Java Programs within a Linux Terminal can be daunting. But worry not, as we have got you covered. Java is a popular programming language used to build all types of applications. With its object-oriented approach and easy-to-understand syntax, Java is considered one of the best programming languages to start with and grow with. It is supported by Linux, macOS, and Windows. However, most Linux users prefer to do things on the terminal, and running Java Programs on the terminal is no exception. This guide will demonstrate the steps to set up a Java environment on Linux so&hellip;<\/p>\n","category_list_v2":"<a href=\"https:\/\/draculaservers.com\/tutorials\/category\/linux-tutorials\/\" rel=\"category tag\">Linux Tutorials<\/a>","author_info_v2":{"name":"Abdul Mannan","url":"https:\/\/draculaservers.com\/tutorials\/author\/abdul-mannan-tbgmail-com\/"},"comments_num_v2":"0 comments","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Run Java Programs in Linux Terminal? - Dracula Servers Tutorials<\/title>\n<meta name=\"description\" content=\"Ensure the installation of JDK, compile the Java code into a Java Program, and then run the Java Program through the Linux Terminal.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Run Java Programs in Linux Terminal? - Dracula Servers Tutorials\" \/>\n<meta property=\"og:description\" content=\"Ensure the installation of JDK, compile the Java code into a Java Program, and then run the Java Program through the Linux Terminal.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/\" \/>\n<meta property=\"og:site_name\" content=\"Dracula Servers Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-30T10:00:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-30T17:12:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abdul Mannan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abdul Mannan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/\"},\"author\":{\"name\":\"Abdul Mannan\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ac89d0281f4fb596bfaa0bc1e746c8a6\"},\"headline\":\"How to Run Java Programs in Linux Terminal?\",\"datePublished\":\"2024-06-30T10:00:03+00:00\",\"dateModified\":\"2024-06-30T17:12:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/\"},\"wordCount\":1149,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-1.png\",\"keywords\":[\"Java\",\"Java Coding on Linux\",\"Java on Linux Terminal\",\"linux\",\"Linux Guides\"],\"articleSection\":[\"Linux Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/\",\"name\":\"How to Run Java Programs in Linux Terminal? - Dracula Servers Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-1.png\",\"datePublished\":\"2024-06-30T10:00:03+00:00\",\"dateModified\":\"2024-06-30T17:12:17+00:00\",\"description\":\"Ensure the installation of JDK, compile the Java code into a Java Program, and then run the Java Program through the Linux Terminal.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#primaryimage\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-1.png\",\"contentUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-1.png\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/run-java-programs-linux-terminal\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Run Java Programs in Linux Terminal?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\",\"name\":\"Dracula Servers Tutorials\",\"description\":\"Dedicated Servers\",\"publisher\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\",\"name\":\"Dracula Servers\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/06\\\/dracula_full_logo_smaller.png\",\"contentUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/06\\\/dracula_full_logo_smaller.png\",\"width\":1625,\"height\":200,\"caption\":\"Dracula Servers\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ac89d0281f4fb596bfaa0bc1e746c8a6\",\"name\":\"Abdul Mannan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"caption\":\"Abdul Mannan\"},\"description\":\"An individual trying to decipher the enigmas of technology by the sheer driving force of curiosity. Interested in learning new skills and being better at those skills than the lot.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Run Java Programs in Linux Terminal? - Dracula Servers Tutorials","description":"Ensure the installation of JDK, compile the Java code into a Java Program, and then run the Java Program through the Linux Terminal.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/","og_locale":"en_US","og_type":"article","og_title":"How to Run Java Programs in Linux Terminal? - Dracula Servers Tutorials","og_description":"Ensure the installation of JDK, compile the Java code into a Java Program, and then run the Java Program through the Linux Terminal.","og_url":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/","og_site_name":"Dracula Servers Tutorials","article_published_time":"2024-06-30T10:00:03+00:00","article_modified_time":"2024-06-30T17:12:17+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png","type":"image\/png"}],"author":"Abdul Mannan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Abdul Mannan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#article","isPartOf":{"@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/"},"author":{"name":"Abdul Mannan","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/person\/ac89d0281f4fb596bfaa0bc1e746c8a6"},"headline":"How to Run Java Programs in Linux Terminal?","datePublished":"2024-06-30T10:00:03+00:00","dateModified":"2024-06-30T17:12:17+00:00","mainEntityOfPage":{"@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/"},"wordCount":1149,"commentCount":0,"publisher":{"@id":"https:\/\/draculaservers.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#primaryimage"},"thumbnailUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png","keywords":["Java","Java Coding on Linux","Java on Linux Terminal","linux","Linux Guides"],"articleSection":["Linux Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/","url":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/","name":"How to Run Java Programs in Linux Terminal? - Dracula Servers Tutorials","isPartOf":{"@id":"https:\/\/draculaservers.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#primaryimage"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#primaryimage"},"thumbnailUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png","datePublished":"2024-06-30T10:00:03+00:00","dateModified":"2024-06-30T17:12:17+00:00","description":"Ensure the installation of JDK, compile the Java code into a Java Program, and then run the Java Program through the Linux Terminal.","breadcrumb":{"@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#primaryimage","url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png","contentUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-1.png","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/draculaservers.com\/tutorials\/run-java-programs-linux-terminal\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/draculaservers.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to Run Java Programs in Linux Terminal?"}]},{"@type":"WebSite","@id":"https:\/\/draculaservers.com\/tutorials\/#website","url":"https:\/\/draculaservers.com\/tutorials\/","name":"Dracula Servers Tutorials","description":"Dedicated Servers","publisher":{"@id":"https:\/\/draculaservers.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/draculaservers.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/draculaservers.com\/tutorials\/#organization","name":"Dracula Servers","url":"https:\/\/draculaservers.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2016\/06\/dracula_full_logo_smaller.png","contentUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2016\/06\/dracula_full_logo_smaller.png","width":1625,"height":200,"caption":"Dracula Servers"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/person\/ac89d0281f4fb596bfaa0bc1e746c8a6","name":"Abdul Mannan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","caption":"Abdul Mannan"},"description":"An individual trying to decipher the enigmas of technology by the sheer driving force of curiosity. Interested in learning new skills and being better at those skills than the lot."}]}},"_links":{"self":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/3096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/comments?post=3096"}],"version-history":[{"count":1,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/3096\/revisions"}],"predecessor-version":[{"id":3108,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/3096\/revisions\/3108"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/media\/3107"}],"wp:attachment":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/media?parent=3096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/categories?post=3096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/tags?post=3096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}