In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about some differences in the development process of Java and .NET. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.
Net platform under the C # language development for a long time, recently the project began to use JAVA to develop, through their own development process of some feelings about their specific development process differences, because the experience and knowledge is still limited, can only from the more superficial and their own commonly used functional points to explain the differences I see.
I use VS2008 and VS2010 to develop. Net programs, and MyEclipse8.5 to develop JAVA programs. The following is a simple explanation from the differences of IDE, language and plug-ins.
The differences of IDE:
It gives me the impression that it is very convenient for MyEclipse to write and view code in the development process, and there are even many features that VS does not have. Here are some of the differences I have encountered:
1. After a variable field is selected, the background colors of the other fields are automatically highlighted to make it easy to see where the variable is used. VS2010 did not have this feature before.
2, for a curly braces or parentheses of the code segment, double-click after the symbol, automatically select the brackets inside the code snippet, which is convenient to view a code snippet, VS does not have such a function.
3. MyEclipse does not have the same code snippet area as # region,#endregion in VS. In a method or class, you can # region function points. Endregion folds the code snippet in this way, and MyEclipse can't achieve this effect unless you use some other plug-ins.
4, Ctrl+alt+t and Ctrl+alt+r keyboard shortcuts, this shortcut key in MyEclipse is very useful, you can quickly find the workspace type or resource, you can quickly fuzzy match to find files or a certain type of file, but VS does not find such a function.
5. MyEclipse intelligent reminder is relatively simple by default, as long as it is entered. After the automatic reminder, in the window- > preferences- > Java-Editor- > Contenet Assist tab in the Auto-Activation box Auto activation triggers for Java can be set to .abcdefghijklmnopqrstuvwxyzABCDEFGHIJLMNOPQSTUVWXYZ, after this setting, enter any letter in the MyEclipse can prompt, but it is case-sensitive, unlike VS enter lowercase a can also intelligently prompt the type of variables starting with uppercase A.
6. MyEclipse often encounters coding problems, which is very inconvenient for beginners. It can be divided into two cases: file opening garbled, and submitting request Chinese content garbled. When the workspace includes multiple projects, it is possible that one project is encoded with GBK, and the other is UTF-8, which will lead to a single file garbled, set the entire project code in Window- > Preferences- > General- > Workspace select the Other setting in Text file encoding, and select the Other setting in Text file encoding in Project right-click Properties- > Resource for individual projects. For JSP and other submission requests, the default encoding is ISO-8859-1, which often leads to garbled codes. You can set the encoding of different files in Text in windows- > Preferences- > general- > Content Types. But VS does not have so many garbled problems, and it is not easy for beginners to have garbled problems.
7. MyEclipse often prompts memory problems such as memory overflow, which is also confusing for beginners, which is often caused by insufficient default configuration of memory. Modify the configuration parameters under-vmargs in myeclipse.ini. For example,-Xmx912m means * * allocate heap memory 912m MaxPermSize556m means * * allocate non-heap memory 556m, which can make MyEclipse memory available. However, some memory overflows may be caused by JVM memory overflows, so you need to set the memory parameters of JVM separately. In window- > preferences- > Java- > Installed JRE, select the default JDK, then select Edit, and configure the relevant parameters in Default VM Arguments. If the program you are running is a WEB program, you may also need to set the memory settings for Tomcat. Go to window- > preferences- > MyEclipse- > Servers- > Tomcat, select the corresponding version of Tomcat, then select the JDK node inside, and set the memory parameters in Optional Java VM arguments. Relatively speaking, VS will not be so troublesome to deal with, generally do not have to set memory parameters.
8, debugging code, VS shows more powerful than MyEclipse, they can modify the value of existing variables in the breakpoint, but VS in the monitoring temporary variables box input variables can also intelligently prompt their own code, while MyEclipse can not automatically remind, and VS can drag breakpoints to the already running code, this function is very powerful and useful in debugging problems, but MyEclipse can not drag breakpoints.
9. The default Ctrl+ left click can quickly locate the definition of the field or type, just like F3, but I think it is easier to develop the ctrl+ left button, which is more convenient than the default F12 quick positioning in VS. Moreover, after it integrates Spring, the Ctrl+ left button can choose to locate to the sub-implementation code of the injection interface, so you can easily view the implementation code, while VS uses Spring.net integration. This function is not provided.
10. Right-source in MyEclipse, which can have many convenient functions, such as generating getter,setter and inheriting interface parent methods.
11. The JAVA project is opened by import, not by double-clicking the .sln or .csproj file in VS. But after opening it once, and next time you open MyEclipse, it will automatically load the project that has already been opened. VS can only open one solution at a time, and the solution includes different projects. If you add a new solution, you will need to open it separately next time.
12. MyEclipse imports a new project. If the JRE version is different, you need to use the local JRE version. Right-click the project-> Build Path- > Configure Build Path- > Libraries- > Java Build Path to modify the JRE version, but sometimes there will be compilation problems, because you do not select the compiled JDK version, and the project right-> Build Path- > Configure Build Path- > Java Compiler modifies Compiler compliance level. For VS, it is convenient for high-version code to open lower-version code and upgrade automatically, or to manually select which version to compile under. Net.
13, MyEclipse double-click the Tab column of the file in the code editing box, you can switch between full-screen code editing block and multi-box display, which is a little more convenient than VS. There is a Link Vith Editor button next to the Package Explorer box, which can quickly locate the location of the file in the package, which is also more convenient, but after right-clicking a file in VS, you can directly choose to open the corresponding physical file directory. There is no this function in MyEclipse.
The differences between languages:
The Java language is very similar to the C# language. Although there are many internal differences and the API provided is not the same, the ideas for developing a specific feature point are often the same. Due to the lack of contact with relatively new technologies and features in the development process, the differences I have encountered include:
1. The name of the Java package corresponds to the location of the physical file one by one. The namespace in C # can be written freely, and the compiled assembly can also be changed without being consistent with the namespace. The assembly is similar to the jar package typed separately in JAVA.
2. A file of JAVA can only have one public class, while C # can have multiple public classes in one file.
3. If you find a JAR package, and Java looks at the method field description of the new jar package, you need a separate doc document corresponding to the jar package before you can see the description of the API call parameters, otherwise it does not look intuitive, but if you have a jar package typed by source code, you can easily see the source code of the package when debugging. As long as you have the dll file in .NET, you can easily see the method metadata call parameters, but if you see the detailed description of the parameters, you still need the xml document of the corresponding dll.
4. For WEB development, Filter,Servlet,Listener is very common in JAVA. Filter in Java can use module in .NET to achieve some functions, but Filter can define the scope of action request, and module is controlled globally. Servlet is equivalent to a specific handler, which can process the formulation request. Listerner can use Application_Start in .NET to complete some functions, but JAVA integrates part of the default Listerner, which starts when the WEB application starts. Their specific execution process is as follows: when WEB starts, the ContextInitialized method of Listener-> the Init of all Filter (regardless of the value of filter-mapping)-> all the init methods configured with Servlet whose load-on-startup is greater than or equal to 0 (regardless of the value of servlet-mapping). The specific request is: init of specific Servlet (execute only once)-> Filter doFilter (value of filter-mapping requested configuration)-> Servlet service; * * website release execution order is: Filter destroy- "Listener contextDestroyed.
5. The Final keyword in Java. When given to a field, it means that the field cannot be modified, nor can it be modified in the constructor. This is similar to const in C #, but const is static by default. Readonly is also similar to C #, but readonly can be modified in the constructor. When it is used as a method modifier, it tries the sealed class of c # and cannot override it.
6. There is no static constructor in Java. If you want to achieve some initialization work, you need to use a static code block, static {. }, you can enter the content inside. C # can only say the static constructor.
7. There is a concept of constant pool in JAVA, which is a different area from heap and stack. Although String, like C #, has a string residence mechanism, it is different from .NET. Therefore, string comparison in java * is compared with equals, otherwise there may be a problem. For example, "a" + "b" strings are in the constant pool, if they are compared with "ab", they will be equal, but "a" + b ab b is a variable, it will be put into the heap, if you also use = = "ab" judgment will return false, so JAVA try to use equals to judge strings, but .NET does not involve this problem, the calculated string, = = the result will be equal.
8. Every file in Java can be run as long as it has a Main method entry, while in .NET, the project type needs to be changed to a console application, and then there is a Main method to be used as a carrier for running.
9. The number range of Byte type is different. In Java, it is from-128to 127. Net is 0255.generally, you need to exchange data with each other and convert it to hexadecimal, and then take the last two bit of 8bit, so that their values are the same, which is convenient for synchronous encryption, decryption or related processing.
10. It is recommended to use get,set method to assign and obtain values to internal variables in Java. In .NET, you can use field get,set to obtain values, and you can directly get;set; after vs2008. With the help of syntax sugar, the compiler will automatically generate equivalent internal get,set fields.
11. JAVA files are automatically compiled by default after saving, but this is also due to the fact that it compiles each java file into a class file, and .NET needs to compile the project separately, because it is a dll file for each project. If you save one of the .cs files to perform compilation, the workload will affect the development speed too much.
12. List in Java is an interface. New List has already reported errors for those who are used to using List collections in C #, and their generics are not the same. C # supports generics in CLR layer, while generics in JAVA are not supported by JVM, so there is no improvement in performance.
13. The default modifier in JAVA is visible in the package (corresponding to the same folder directory, not under the large jar package of the project). The variables and methods of protected are visible in the package and subclasses, and only themselves and subclasses are visible in .NET. The default modifier for classes in .NET is Internal, which is accessible within the assembly. Methods and fields default to private, which is different from what is visible in the default package of JAVA.
The differences between plug-ins:
1. MyEclipse itself is a plug-in, which integrates a large number of open source frameworks, while VS is a unified IDE of Microsoft. To use other open source plug-ins, you need to download and configure them separately.
2. There are many ways to achieve webservice in Java. In addition to the only version of the JAX-WS,java webservice specification in the javax.jws package, there is also axis,xfire 's open source implementation of webservice. Axis, including axis1,axis2,xfire, has been renamed to cxf, but various implementation methods are different. When calling each other with the webservice released by .NET, you often encounter some problems. Generally speaking, Java has more stringent requirements on the format of wsdl.
The above are the results of analysis and arrangement according to the problems encountered in the recent development process, the area involved is limited, we need to constantly improve the relevant technical points in the future, and the results of arrangement and understanding may not be completely accurate, if there are any questions, please correct.
These are some of the differences in the development process between Java and .NET, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.