preface

C: As the old saying goes, “To do a good job, you must sharpen your tools.” In our last post, we started writing our first Java program and experienced some “stumbles” caused by word capitalization, as well as deep “malice” from Chinese input methods.

So we’re done with them? Will you only know the error until the last run or separate debugging? In fact, for such syntax errors, we can use a professional tool, in the process of writing code to solve the professional tool is called: IDE.

Today, Teacher Cha will take you to appreciate a mature and charming Java IDE.

A series of reading

  • The Java syntax | Eclipse person”

  • The Java syntax | programs that something”

  • The Java syntax | variables and constants,

  • The Java syntax | common operators”

IDE(Integrated Development Environment)

Summary of the IDE

In the introduction, Zha has briefly talked about the capabilities of IDES, which can solve the above problems, but also make it easier to compile and run programs, especially if you use the shortcut keys, you may lose your mouse! But in the early stage, Teacher Zha suggests you, don’t rush to use IDE shortcut keys, first practice typing speed and complete grammar.

Introduction to mainstream ides

We are now learning the Java language, so it is natural to choose an IDE suitable for Java development. There are several major Java ides in the industry.

  1. Eclipse

    The open source, free Java IDE, maintained by the Eclipse Foundation, has versions or plug-ins developed for various programming languages. In Teacher Zha’s opinion, its software volume and use more suitable for the initial and entry-level programmers.

  2. IntelliJ IDEA

    JetBrains, a company that makes IDE versions for a variety of programming languages, is a Java IDE that charges a fee but is used by many whoremonders. For example: WebStorm for front-end development, PhpStorm for PHP development, PyCharm for Python development, etc., are also “expensive”. So in the legal fees and crack learning struggle, domestic developers still need to go very far.

  3. MyEclipse

    But a lot of “legacy companies” still use Java IDES, a software whose name is associated with Eclipse, and it is. It comes out of the Eclipse community, and you can interpret it as Genuitec’s VIP version for Java EE developers, which is Java EE-friendly. In fact, after learning Eclipse, MyEclipse is almost the same.

  4. VSCode(Visual Studio Code)

    Free, Microsoft, essentially an editor, not an IDE. However, there are a lot of foreign use, need to install their own plug-in configuration to support more functions, for the novice or more trouble.

Teacher zha said: about IDE specific which good, zha teacher finally euphemism: the learning stage, “funds”, personal habits, the company team decided to use which one, Zha teacher just from the market to take you selective learning, did not cause the meaning of “IDE jihad “.

The fallen royal IDE

Handy ides are always fascinating in the development process. Of all the Java ides, Mr. Cha prefers Eclipse, if only from the perspective of initial learning advice and feelings. Free, good scalability, good initial use experience, relatively simple, these are the reasons teacher Zha recommended to the initial developers.

Although in the past two years in the middle and advanced development has declined, but does not prevent us from learning in the early stage.

Summary of the Eclipse

Ok, so let’s go back to Eclipse, which may not have been very impressive at first glance. Eclipse is an open source, free Java IDE maintained by the Eclipse Foundation, with versions or plug-ins developed for various programming languages. In Teacher Zha’s opinion, its software volume and use more suitable for the initial and entry-level programmers.

In early 2020, Jrebel released the Java Technology Report 2020, a statistical analysis of the Java technology ecosystem from nearly 400 responses from Java development professionals around the world. In the IDE usage analysis report, 24% of people use Eclipse, second only to IntelliJ IDEA.

In PYPL’s TOP IDE hot list, Eclipse has always been the second most popular. (It is also related to the many programming language versions of Eclipse that are called Eclipse).

These latest numbers look good, but in fact they were even more impressive earlier. Only around 2017, JetBrains’ products became popular in China.

Such as: With the rise of modern development technologies such as Spring Boot framework, JetBrains adapted IntelliJ IDEA products developed by Java quickly occupied the Market of Eclipse with more convenient and fast advantages. Eclipse users are defecting to the enemy (but Eclipse is failing in modern development, so what can be done about it? Many programmers jump from Eclipse to IDEA and never get back). Below is the recent topic discussion between IntelliJ IDEA and Eclipse.

Okay, this is just a quick way to get you up to speed, to see the world, so you don’t get confused.

After all, this is the home of Eclipse, and Zha won’t tell you too much about other IDE products. To learn more about Eclipse’s ecological position in different languages, Google.

The Eclipse download

Next, we are going to download Eclipse. There are two ways to download Eclipse official website, one is Installer (EXE installation Package, bootstrap installation), the other is Package (zip Package, decompression can be used, similar to green software).

Teacher Zha’s personal suggestion is to download it in the form of Package. Click download.

Three things to keep in mind before downloading:

  1. Note that the Eclipse you want to download matches the JDK version you installed

    See the Official introduction of Eclipse.

    The Eclipse version Starting time JDK version
    Eclipse 4.5 June 24, 2015 1.7
    Eclipse 4.6 (Neon Neon) June 22, 2016 1.8
    Eclipse 4.7 (Oxygen Oxygen) June 28, 2017 1.8 and above, 1.9 recommended4.7.1 aAnd above
    Eclipse 4.8 (Photon) June 27, 2018 1.8 and above
    Eclipse 4.9 (2018-09) September 19, 2018 1.8 and above
    . . .
    Eclipse 4.15 (2020-03) 18 March 2020 1.8 and above, 32-bit JVMS are no longer supported
  2. Note that the Eclipse to be downloaded matches the JDK bits installed (either 32-bit or 64-bit)

  3. Note that the Eclipse you are downloading fits your computer system and the bits

We are currently using JDK 8. Download the latest version of Eclipse (version 2020-03).

Time is changing, the latest version of the future that Teacher Zha refers to may not be the present one, but teacher Zha will update the content only when there is a large change, so choose the latest version when you open it.

In the download confirmation page, we can click Select Another Mirror to Select Another Mirror source, you can choose a domestic Mirror source, otherwise the download will take too long.

Click to enter the Eclipse donation page, where the culture of giving is prevalent abroad to support these non-profit organizations. If you don’t want to donate, wait on the page for a while. The page should automatically start downloading or pop up a download prompt. If it doesn’t start, you can just click here to start downloading.

After a while, an Eclipse ZIP installation package is ready to download.

Eclipse installation

Check the teacher just download way, download is zip format compression package. It is like some cracked version of green software you usually download, do not need to double-click the.exe installation program for boot installation, just need to unzip to use.

Right-click on the package and find a place to unpack it. You’ll want to put it in your own developer installation directory (for example, the Develop folder you suggested earlier).

Uncheck, otherwise extract the content with an additional compressed package folder of the same name.

After decompression, find the location of decompression. The.exe ending is the launcher. To quickly open it later, you can right-click it in the pop-up menu and send it to the desktop shortcut.

Then we can double-click the.exe program, or double-click the shortcut to open Eclipse.

As long as you have checked the above three downloads, and the JDK JAVA_HOME configuration in accordance with the requirements of the teacher to do, theoretically there will be no other problems. If JAVA_HOME is not configured, the result is shown below.

Check the teacher say: if you are a win 10 also could be some compatibility issues: we environment variable configuration obviously, but still hint below, this time need you to look at the JAVA_HOME again, don’t even need to move, to see the environment variable and then determine the shut down, this problem was part of the students there appeared many times.

When opened, the first window that pops up will ask you to select or enter a folder address for your workspace. The folder will be created automatically if it doesn’t exist. Eclipse uses this workspace to store your code, projects, and configuration.

Note: if you switch workspaces, your configuration, etc., will need to be reset. Different workspaces are independent of each other.

After entering, the Welcome interface is displayed. Click close the Welcome TAB to enter the main interface of the program.

Eclipse Initial Configuration

A good tool must be tuned if it is to be used well.

View Window configuration

The main screen, of course, means we’ve installed successfully. The download itself is Eclipse for Java EE development, so when opened, Eclipse is in the Java EE view by default. But Teacher Cha likes to operate in the Java view, so we need to switch the view. Different view modes, some Windows and menus are not the same, it is recommended to use Java view mode first.

Click the Open Perspective button, in the dialog that pops up, select Java, and then click Open to switch to Java View mode.

Can learn to use in the future, gradually close some of their own TAB window, you can also adjust the position of each TAB window. If you mess it up, just right click on the view name in the upper right corner and select Reset to return the view window to its original state.

In addition, you can add some tabbed Windows in the Show View option of the Window menu.

For example: the Console Console that we will use later.

Finally, the initial adjustment of the window effect is as follows, you use for a long time, and then adjust according to their own habits.

Character encoding configuration

GBK is used as the default character encoding in Eclipse, but in order to solve the encoding problems we developed later, we required the unified character encoding configuration and changed the default character encoding to UTF-8. Because this character encoding has better applicability, for Chinese and foreign language support is better.

Click Window > Preferences, and basically all of Eclipse’s Settings are there.

Enter workspace in the search box, then select the options illustrated, set the text file encoding to Other > UTF-8 in the window on the right, and then hit Apply and Close.

Font configuration

Last configuration, how can I write code without a proper font and size?

Open the preferences window again and go to General > Appearance > Colors and Fonts > Basic. Then click the last Text Font in Basic. Double-click or click Edit to enter the modification screen.

Generally speaking, the default font is Consolas, with simple size changes for easy viewing. After selecting the font, click ok to apply successfully.

In fact, Eclipse now supports adjusting the size of text in the editing area by pressing Ctrl + or – during text editing.

JetBrains also has a set of fonts for developers that it says will reduce eye strain. If you need one, download it from JetBrains.

Develop Java programs with Eclipse

Now that we’re done, let’s use Eclipse to develop a Hello World program. Is it simpler than we did in chapter 1?

Developing Java programs with Eclipse can be divided into four steps:

  1. Create a Java project (a complex program will definitely require a lot of source code files, so we’ll organize the source files by project)
  2. Manually create Java source programs
  3. Compile the Java source (this step is automatic in Eclipse)
  4. Running a Java program

First, we open Eclipse with the configuration, click on the File menu, and select Java Project from the New submenu to create a New Java Project.

Enter the project name and verify that the JRE runtime is automatically specified (if JAVA_HOME configuration is correct, it should be). This is critical to determine whether the code can be written and compiled properly.

Here is a basic Java project created.

So where do we write the source code that we wrote before? The answer is to write in the SRC (source) source directory. Instead of creating the source files directly under the SRC root directory, create a Package organization called Package.

Teacher Zha said: The name of the Package is composed of the reverse order of the company’s domain name, for example: Baidu company writes com.bidu. XXX, and the words of the Package name are all lowercase.

Right click the SRC directory, then New a Package, enter a custom Package name, and Finish.

Once you’ve created the package, right click the package name to create the class, which we wrote about directly in the last article.

The pulic class XXX class declaration is now done quickly in Eclipse. You don’t have to write it anymore. You can just write the main method and the content.

If you stop writing and you’re not finished writing, Eclipse will say something wrong, which is normal.

A spark with lightning code knock write, very comfortable to finish the content of the previous, but also highlight and part of the return auto indent function.

Once you have entered the code, you need javac to compile it before you can run it in Java. Now that you have Eclipse, right click in the margin of the code. Choose Run As > Java Application from the menu that pops up (Eclipse automatically compiles it for you).

In fact, Eclipse is still working in the same way as we did in the previous article, but a lot of things have been classified for us and done some automatic processing.

Open the workspace address yourself and you’ll see that the Java project you just created is actually a special multilevel folder. So don’t worry about Eclipse, it’s not as difficult as you think, take your time and be good at it.

Afterword.

This concludes our initial understanding of Eclipse. Eclipse also supports changing themes for your own interest. Other configurations, when we need them in the future, will be explained accordingly, which is enough for now.

In addition, many students like to use the Chinese version of the software in the early stage, but they do not know that in many IDES, the Chinese version is not very much, especially terrible after dependence, so there is “Chinese cool, XXXX” said.

For us, most programming languages are In English, and if we use tools in Chinese, it is not only unprofessional, but also a waste of a great opportunity to learn English!

So remember teacher Cha’s advice, do not sinicize.

Here’s another Eclipse rumor: It is said that the abbreviation of the original SUN company is the meaning of the SUN, and SUN company is really in the prime of the day because of Java, second to none in the Internet industry, so IBM hopes to create a product to cover the rays of the SUN, so named eclipse(eclipse).

Which is true and which is not known. Just be kind to this open source IDE that will be with us for a long time.

Teacher Zha said: For the learning of technology, teacher Zha has always followed the following steps: With a simple demo to let it run first, and then learn it the most commonly used API and configuration can let yourself up, finally, on the basis of proficiency in the spare time reading the source to try to make myself to be able to see clearly its running mechanism, part of the cause of the problem, at the same time, draw lessons from these technology to enhance your own code level.

So in the teacher’s article, the early basic are small white, only interspersed with a very small amount of source research. Of course, such as the small white update, you still like, the late will not regularly dedicated to part of the technology of the source code analysis.