First, preface
- Why write Java versus. Net?
. NET is born with the shadow of Java. From imitation to innovation,. NET platform is becoming more and more mature. Their different supporters are often vexed by the question of which is weak or strong. But this article is not for the sake of one. Instead, compare the Java platform with the. NET Platform. Focus on Project building, web framework, project deployment. I believe that through these discussions can let java/. NET engineer to the Java platform,. NET platform to have a better understanding.
Ii. Construction of the project
工欲善其事 its prerequisite. Development environment Configuration + tool use of course you have to speak first.
1, the surface of the tool
Platform |
Tools |
Ken.io's explanation |
. NET |
Visual Studio |
Microsoft Official IDE, it has developed. NET applications, almost all tools |
Java |
Idea/eclipse |
IDE, responsible for managing the project and running debugging of the code, depending on the JDK |
Java |
Maven |
Responsible for managing project templates, Packaging (jar packages, etc.), relying on JDK |
Java |
Jdk |
JRE (Java Project Runtime Environment), Java tools (compiler, etc.) |
. NET Engineer to work, install Visual Studio ("VS" later) to develop. But Java development, only the IDE is not able to install, even if some of the IDE will automatically install the JDK, or even maven, but these still need to configure their own, or may be stepping on the pit. From the configuration of the development environment,. NET Engineer is really easy to do, keep the next step, wait for the installation to complete. The Java engineer has to understand the tools and the responsibilities of each tool first. Then configure them individually.
From this point on, Java's entry curve will be slightly steeper, but Java engineers will be more concerned about the important aspects of project construction than. NET engineers.
2, the actual tool
Responsibilities |
. NET Platform |
Java platform |
ken.io explanation |
Project Management |
Vs |
Idea/eclips |
. NET only Microsoft Official Ide,java no official IDE, no vs good, but there are multiple options |
Project templates |
Vs+msbuild |
Ide+maven |
. NET project templates are vs comes with, are directly compliant with MSBuild (compiler) standards, the project is organized by the Sln+csproj file, the Java platform compiler standard is public, the current mainstream projects are created based on MAVEN templates, the project is organized by the Pom.xml file. |
Compiling & Debugging |
Vs+msbuild+sdk |
Ide+maven+sdk |
. NET platform compiler is standalone, the Java platform compiler is integrated in the JDK, the MAVEN template project is organized by the Pom.xml file, but the compiler is not aware of Pom.xml, so the compilation requires MAVEN participation |
Package Management |
NuGet |
Maven |
NuGet is Microsoft's official open source vs plugin, and Maven is an open source project under Apache. Ken.io feels maven is more flexible and powerful. NuGet is easy to get started. |
Packaging/Publishing |
Vs+msbuild+sdk |
Ide+maven+sdk |
. NET platform compiler is independent, the Java platform compiler is integrated in the JDK, the MAVEN template project is organized by the Pom.xml file, but the compiler does not know pom.xml, so packaging needs Maven's participation. The IDE mainly provides graphical interface instead of command operation |
From the project management said. Vs This IDE is better with some, on project templates. NET project template because of the presence of Visual Studio, it can be said to be easy to use and rich, the Java platform Maven template flexibility.
In fact, most of the differences are the differences between the compiler and the template. NET platform is independent, compiler MSBuild has a set of standards, and Visual Studio provides a rich and useful project template.
The compiler configuration of the Java platform is an XML document, because Java official does not have a project template, the IDE is only responsible for organizing your project, but there is no template, you can specify any directory as sourceroot (code root), Resourceroot (the root directory of the resource file, such as a configuration file) can also be arbitrarily specified, when compiling, the IDE will tell the compiler how to compile your project code, as well as the compiler's required compilation description/configuration XML document. It's really flexible, but it also increases the cost of project management. Package management is also very cumbersome, fortunately there is Maven end of this chaotic Java world.
- |
. NET |
Java |
Organization of the class |
Namespace: namespace, name not related to directory |
Package:name is consistent with the directory name |
Class |
. cs file: Class name is not associated with file name |
. java files, class names are independent of file names, but a class file can only define one public class |
Compile output |
. dll,.exe file |
. jar,.war file |
III. Framework
. NET Web frameworks are mostly Microsoft official, the official framework is the most popular, and the Java platform, in addition to the official servlet API (equivalent to. NET system.web) Other basic is ruled by the spring big family. This time we are mainly comparing the most commonly used MVC framework and the persistence Layer framework for Web development
function |
. NET |
Java |
Ken.io's description |
Web Core |
asp |
Servlet |
— |
Web Framework |
ASP. NET MVC |
Spring MVC |
ASP. NET MVC is Microsoft's official framework, the srping MVC framework belongs to the spring family, and relies on spring |
View Engine |
Razor |
Thymeleaf/freemarker |
Razor is the official Microsoft View engine, very useful, Spring MVC does not have a view engine, but there are thymeleaf,freemarker. Ken.io prefers razor style. |
Persistence layer |
Entity Framework |
MyBatis |
EF is Microsoft's Official persistent layer framework that is easy to get started, highly developed, but aggressive. MyBatis configuration is flexible and non-intrusive. Each has its pros and cons. |
. NET platform of the framework because are Microsoft official, relatively good organization, easy to get started. The framework of the Java platform, flexible and configurable. This is also the Java platform consistent style. But Ken.io had to spit out that Spring MVC, as an MVC framework, had no view engine of its own, where is the MVC view?
It is possible that Java, as the main platform of the Web backend, does not really pay much attention to the view layer, but spring MVC does not have a view layer engine, or it feels inappropriate. Thymeleaf and Freemarker,ken.io more recommended freemarker. Because Ken.io prefers Freemaker's grammar. It may have been used for razor's sake.
Iv. deployment of the project
For project deployment: NET platform seems to have no choice, only choose Windows+iis, although there is mono, but after all, not support all the class library. The Java platform can choose either Windows+tomcat or Linux+tomcat. But usually the choice of linux+tomcat cost is low after all.
Responsibilities |
. NET |
Java |
Operating system |
Windows Server |
Windows Server, Linux server |
Web server |
Iis |
Tomcat (Tomcat is currently the most mainstream, and there are other servlets that are easy for example: JBoss) |
But the Java platform features, Java Project deployment will be more cumbersome than the. NET project deployment.
The IIS graphical interface is the next step, and then you can adjust the version of the application pool. Tomcat, both in Windows and Linux, completes the site configuration by modifying the configuration file.
Five, PostScript
Both the Java platform and the. NET platform have their advantages. Platform is just a tool, we understand the platform is to make a better choice. But it has to be said that the Java open source ecosystem is developing rapidly, not other platforms comparable, however. NET platform is also making up for its own short board and launched the. NET Core. Expect the future to thrive in both Java and. Net.
. NET program Ape, if you want to learn Java, you can take a look at Ken.io written tutorial
Java QuickStart Series Tutorial: Https://ken.io/serie/java-quickstart
Spring Boot Getting Started Tutorial: Https://ken.io/serie/springboot-course-basic
Java Program Ape, if you want to learn. NET, we recommend starting with. NET Core:
. NET Core Quick Start Tutorial: http://www.cnblogs.com/ken-io/p/dotnet-core-quickstart.html
If you want to communicate with the technology can access the connection Scan code join QQ Group: Https://ken.io/home/about
- This article was first published: 2017-07-31
- This text link: https://ken.io/note/java-vs-dotnet
This article is not intended to lead the war, this at the beginning of the time also made a description. In addition, I. Net,.net Core,java are in use, without the intention of any black platform.
If a friend does not agree with the views of this article, welcome to comment on the exchange, silently point out the objection, I do not know why you oppose, right?
Java VS. Comparison of Net:java and. NET Features