how to write,compile and run java program on linux

Posted: 23 Jul 2016 in short notes
Tags: , , , ,

This tutorial is all about how to write compile and run java program in redhat enterprise linux.Here i have mentioned all steps which is essential to run a java program in linux.Before you go through this tutorial let me remind you all that i assume that you have already configured yum server on your redhat enterprise linux machine or you already have idea about how to configure yum server in linux.

If you don’t have idea about how to configure yum server on linux watch this video.

So let’s begin writing compiling and running java on linux.

Step1: install java package using yum

#yum install java*    -y

Step2:Write your java program.Your program name can be anything but extension must be .java.

#vim  helloworld.java

public class helloworld 
{
public static void main(String[] args)
 {
System.out.println("Hello satish how are you?");//display the string
}
}

Save and exit

Step3:Compile your java program using java compiler named javac

#javac helloworld.java

Step5:Run your java program.

#java helloworld
Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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