Eight tools commonly used by java programmers

The following 8 tools, from code building to bug squeezing, cover the universe of Java development. Learning these tools can help you improve your code quality and become a more productive Java developer.

1.Eclipse

Despite the growing popularity of IntelliJ IDEA, NetBeans and some other IDEs, surveys show that Eclipse is still the preferred development environment for almost half of Java developers. Eclipse is the Swiss Army Knife of IDEs, with tons of custom interfaces and countless plugins. It's ubiquitous, and all the other tools that I'll recommend later in this article provide Eclipse plug-ins.

Eclipse's workflow can be divided into three areas: workbench, workspace and perspective. The workbench serves as the starting point to the IDE. A workspace combines projects, files, and configuration settings under a single directory. Perspectives define tools, views, and valid settings. While novice developers may find Eclipse more difficult to use than Netbeans and IntelliJ IDEA, Eclipse's flexibility makes it the IDE of choice for enterprise development.

Luna, the latest version of Eclipse, supports Java 8, split-screen editing, a new dark theme, and a fully functional command line terminal.

Official website: https://eclipse.org/

2.Gradle

Gradle is an automated project tool built on the capabilities of Apache Maven and Apache Ant. While Gradle isn't the most popular build tool (the most popular being Maven, chosen by 64% of Java developers), its popularity is fast. It is also available as the default Android build tool.

Gradle prides itself on its simplicity. Gradle uses the Groovy programming language, as opposed to the XML syntax used by Maven and Ant. A basic Gradle build file consists of a simple line of code:

apply plugin: 'java'.

The following command generates a Gradle build file, creates a directory tree of project files, and ships with a project portable Gradle wrapper:

$ gradle init --type java-library

Gradle also has plugins that can be used to add new languages, generate IDE-enabled project files, build local binaries, check for dependency updates, and more.

For more information, see Gradle's Java/JVM Getting Started Guide .

Official website: https://gradle.org/

3.Javadoc

Javadoc is a documentation generator provided by Oracle. It can parse specially formatted comments into HTML documents. The following screenshot is the Java SE 8 API specification generated by Javadoc:

Javadoc comments use the format of opening tags, closing tags, and one or more descriptive tags. Open tags are similar to standard Java multi-line comment tags, except that two asterisks are used. Javadoc also parses normal HTML tags.

Javadoc automatically formats tags and keywords unless otherwise specified. Javadoc makes extensive use of hyperlinks, allowing you to reference and link to different areas of the code. Many IDEs - including Eclipse - can automatically add Javadoc comment modules to variables, classes and methods. Plugins that support Maven, Gradle and Ant build Javadoc HTML while compiling the code.

For more information, see Oracle's article on how to write documentation comments for the Javadoc tool .

Official website: http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html

4.JUnit

JUnit is an open source framework for writing and running unit tests. A basic JUnit test consists of a test class, a test method, and the functionality to execute the test. JUnit uses annotations to determine how tests are constructed and run. For example, if your program has a class called MathClass with methods for multiplication and division, you can create JUnit tests to check for unexpected values. Enter the numbers 2 and 5 into the Multiply method, and you want the result to be 10. When entering 0 as the second argument to the division method, you would expect to give a warning that the number was not calculated properly because the divisor cannot be 0:

The @Test annotation specifies that the MathClass method is a test case. Provide additional annotations in JUnit, such as @Before, so that you can set the environment before the tests are run. JUnit can also set up rules that define the behavior of test methods. For example, the TemporaryFolder rule causes files or folders created by the test to be deleted once the test is complete.

For more information, see Getting Started with JUnit . There are also tutorials for unit testing with JUnit.

Official website: http://junit.org/

5.Coverage

Cobertura can be used to analyze the test coverage of Java code. Cobertura generates HTML-based reports from code not covered by tests.

Cobertura provides tools that can be used to instrument, inspect, and test code. By monitoring testable code, Cobertura allows you to use the testing framework of your choice and even run the program without a testing framework.

Cobertura gives code coverage reports in terms of lines, branches and packages. Each category has a customizable threshold that triggers an alert if reach falls below the threshold. Cobertura also integrates with Maven and Gradle's auto-detection capabilities.

Mkyong.com provides an example of integrating Cobertura with Maven .

Official website: http://cobertura.github.io/cobertura/

6.FindBugs

FindBugs is a tool that matches compiled code patterns rather than using a bug database. When source code is provided, FindBugs can also highlight the line of code where the bug was detected.

In its 3.0.1 release, FindBugs continues to hold hundreds of bug descriptions. Based on the severity of the bug, FindBugs categorizes bugs into four levels: relevant, troubling, scary, and most scary. In addition to the GUI, FindBugs also provides a command line interface, Ant tasks, and Eclipse plugins.

Official website: http://findbugs.sourceforge.net/

7.VisualVM

VisualVM included in the JDK is a tool for monitoring and reviewing the performance of Java applications. VisualVM detects and values ​​active JVM instances to retrieve diagnostic information about processes.

VisualVM makes it easy to diagnose performance issues in real-time. It provides a full set of analysis tools, including JConsole, jstack, jmap, jinfo and jstat, etc. Additionally, you can take a snapshot of the JVM so that you can review it later at any time.

Official website: http://visualvm.java.net/

8.Groovy

Groovy is a programming language that both simplifies and extends Java by adding new keywords, auto-importing commonly used classes, and optionally typed variable declarations.

One of Groovy's core strengths is its scripting capabilities. Classes can be compiled to Java bytecode or dynamically executed using the Groovy Shell. Groovy's Java foundation makes it more accessible to Java developers than Jython and JRuby.

For more information, see the Groovy Getting Started Guide .

Official website: http://www.groovy-lang.org/

Other options

New tools, utilities, and libraries are constantly emerging in the big world of Java. If your preferred tool doesn't make the list above, please share.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325047636&siteId=291194637