Java program development under Linux

Source: Internet
Author: User

Tapping on the Linux terminal: Java (for Java program execution)

If there is a large string of characters the output instructions are already installed. (Linux programs install Java by default, but Javac does not seem to be the default)

Percussion: Javac (for program compilation)

If there is a large string of characters the output instructions are already installed.

If there is no need to install first. (Applications need to be installed before they are used)

The installation of the program: said before, the computer system is the only thing is the file, the installation of the program is to download files, white is to put the file down, put on your hard drive on it. (CP)

Download: JDK Latest version: Jdk-7u71-linux-x64.tar.gz placed under your directory (/HOME/XXX), unzip: Tar zxvf jdk-7u71-linux-x64.tar.gz installed successfully.

Go to Jdk-7u71/bin, execute./java./javac can execute the above two commands.

However, there is a drawback is that you have to run the Java command to go to the Jdk-7u71/bin to execute, no one will be prompted to find the program.

If you want to, under a random file path, tapping: Java, can access to the Java program under Jdk-7u71/bin, a concept is the environment variable path.

Terminal percussion: Echo¥path can see the value of the system environment PATH. (A sequence of file paths, i.e. addresses)

The purpose of setting path is that, regardless of the current file path, when you hit a command at the terminal, the shell program will automatically look for the command program in these paths in path, and if found, execute it, if not found.

So you want to hit Java anywhere, you can execute Java under Jdk-7u71/bin, and you'll add jdk-7u71/bin to the path. The specific methods are:

1: Edit File/etc/profile

2: Edit File/home/xxx/.bash_profile

Add to:

Export path= $PATH: Jdk-7u71/bin

When you are finished editing, the environment variables that you set are in effect when you execute Source/etc/profile or/home/xxx/.bash_profile. (Can echo $PATH look)

Summary: The installer generally has two steps 1: Download the program to a local path under 2: Add the path to the environment variable path (This step is intended to be convenient for the call)

Below you can start to develop your Java project (haha is the program)

The simplest:

Vim Test.java

public class test.java{

public static void Main (String [] args) {

System.out.println ("What a Fuck");

}

}

: Wq

Save it, please.

Compile:

Javac Test.java

The function is to generate a Test.class file in the current directory (in the Java language, the Xxx.class file is an executable file, which means that Java has only. Java and. Class two files)

Perform:

Java Test (No. Class)

The screen will output: What a fuck

Summary: Program development is divided into three steps 1: Program writing (VIM) 2: Program compilation (JAVAC) 3: Program Execution (Java)

================================================== Advanced:

The functions or classes that are currently written by Java programs are in the Java language (for example, the system class out class println method in Test.java), Javac will automatically find these classes when compiling the program, and Java execution will automatically find them. So, the development of the example program is very simple.

But if you want to write a larger Java project, it is not possible to use only the Java language comes with the class, the other sentence you can not only use the Java comes with the basic class to build a practical application. We may need to use a class or package or library or plugin that someone else has already written about. (They all represent a thing)

Java program development under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.