Vous êtes sur la page 1sur 5

Difference between JAVA and .

NET

The biggest difference between Java and .NET is the basic philosophy behind the languages. Java is a programming language designed to be run on many different platforms, and so uses a common language which has to be compiled and run on different platforms (eg. windows, mac and linux). Microsoft, with their offering of .NET, takes on a different approach, by allowing you to program in any language you choose, but has compilers for many different languages that generates a platform specific code (i.e. Microsoft or Windows). Therefore, Java can be used to write programs for many different operating systems, and .NET can be used to make any programming language into a Windows program. This is all based on the original design goals of the programming language, and has both advantages and disadvantages over each other. For example, .NET would be good for integrating legacy code from different languages into a working program, when you don't want to re-write each piece of code into the same programming language. Both .NET and Java are otherwise object-oriented programming languages, with their obvious syntax differences. Architecture wise the .NET byte codes gets transformed into a intermediate language and cached as native code before execution. All most Java2 programming is J2ME specific, but I don't think the Java2 VM Sun provides for Windows does, one of our Java2 programmers told me that IBM has a Just-In-Time VM for Win32 that does do this, but it's commerical software and cost $$$ to license. The result of this is that .NET apps run faster than Java2 apps on Windows with the default Java2 VM provided by Sun. Also, Microsoft intermediate language is opened for language developers to build on (it's actually an Assembly Langauge that you can write in if you'd like), so C#, VB.NET, COBOL.NET, J#, etc.. All are compiled into MIL (Microsoft Intermediate Language) if you wanted to create Pearl.NET you could. The .NET VM (aka Common Language Runtime) was built primarly with the Win32 API in mind and is closely knit to the Windows platform. Getting past this the .NET class libraries provide a bit more functionality than the class libraries provided by Sun (not much, just a bit though). This is most just utility items (e.g. In .NET if you want to convert from one data type to another their's a static Convert class that works like a magic box) there are things missing in .NET though (no Vector, but you can make one pretty easy) The primary advantage of .NET (comparing the C# language here to Java2) is that .NET has Visual Studio.NET (so far I've seen no other IDE that can match VS.NET, yes I've tried WebSphere, Eclipse, Borland, Sun One, they all

fall short in some areas). The other advantage is ASP.NET which has stolen the best concepts of JSP, PHP, ColdFusion, and borrowed from classic ASP. ASP.NET is killer for web apps. (Although the Sun One studio for web development is good enough that I probably wouldn't switch to .NET just for ASP.NET at this point) Java's primary advantage is that you have your choice of third-party tools (third-party IDE, third-party application server, third-party web server, etc...) it doesn't bind you to a specific platform and it runs everywhere. If you're doing Windows development use C# and .NET, if you're app has a chance to benefit from running on some other platform use J2EE.

The Major Difference between .Net and Java is 1)Java is a purely Platform independent means the application that will work in any kind of Operating System.But .Net is platform independt software. 2).Net support to develop application in different languages and to develop application Rapidly. This feature is not exist in Java
To seasoned Java developers, .NET may seem similar to the Java platform. Both provide a structured way to create applications, both have languages that compile to intermediate code, and both provide a large library of APIs for application development. However, there are significant differences in the platforms.

Conceptual Difference
Conceptually, Java is two things: the Java platform (runtime and APIs), and the Java language. The purpose of the Java platform is to support applications written in the Java language and compiled to Java bytecode. Although there have been attempts to compile other languages to Java bytecode, these have largely been academic exercises. The ideal of Java has always been a single language on multiple platforms. .NET also is two things: the .NET Framework (runtime and APIs), and the plethora of supported programming languages. The purpose of the NET Framework is to support applications written in any language and compiled to MSIL. The goal of .NET is a single platform shared by multiple languages. This is the primary difference between the two platforms, and its effects are far-reaching.

Multi-language
The most obvious difference between the two platforms is the language. If you're writing to the Java platform, you're writing code in Java. Period. The Java Virtual Machine was designed to execute Java code and although there have been attempts to port other languages to the JVM, those efforts have not been widely accepted or

completely successful. .NET applications, on the other hand, can be written in any language that supports .NET. The .NET Framework SDK ships with three languages: C#, Visual Basic .NET, and Jscript .NET. Microsoft also offers J# .NET and C++ with managed extensions. Third party languages include COBOL, Eiffel, Perl, Python, Pascal, and many others. There currently are over 20 languages that support .NET. And because they all target the Common Language Runtime, programs written in any of these languages can access objects created by any of the other languages.

Framework Classes
Because Java is multiplatform, the set of framework classes has traditionally been limited to what is available on all platforms. This affects both the scope and richness of classes, both of which are limited to the lowestcommon denominator of available computers and operating systems. The built-in Java classes are typically very simple and developers often build their own frameworks on top of them, or have to find third-party frameworks. The .NET Framework is built upon the Windows platform, and the .NET Framework classes offer the full scope of what is available on this platform. Additionally, the classes are richer than what is available in Java: .NET provides a programming framework rather than a base on which to build a programming framework. A typical example of the difference between Java framework classes and .NET framework classes is in the area of forms packages. The .NET Web Forms classes provide a much richer environment than either of the two competing Java forms packages (AWT Abstract Windowing Toolkit, or Swing).

Write Once, Debug Everywhere


While the Java ideal of "write once, run anywhere" is attractive, most applications written today target only one operating system. There are two technical reasons for this: 1. Because the Java framework is limited in scope and richness, developers often use proprietary classes to access features available to the target platform. 2. Because lingering incompatibilities between the various Java implementations have continued to plague true cross-platform efforts, developers must test their code on every platform they wish to support. Because of this, some developers have half-jokingly referred to Java as the "Write once, debug everywhere" platform.

Security

Security is richer in .NET. Along with APIs for cryptography, secure cookies, and authentication, there is also a rich and extensible mechanism for assigning different levels of permissions to different sets of users, based on where the code came from. For example, you can mark all code from a particular vendor as safe. All code from a specific URL can be granted (or denied) read/write access to specific resources such as the temp directory or screen. In addition, applications can be marked as requiring certain permissions (for example, requires access to the file system). If these permissions are not available, then the application will not load. Because the security check is performed at load time, the developer is freed from writing security fail detection logic throughout the application. This is managed through a new technology called "code access security," which works for code loaded from either the Internet or the local machine.

Versioning
The .NET Framework has a more robust versioning system than Java. In Java, if two versions of the same class are installed, the Java runtime will simply load the first class it finds on the classpath, ignoring the version. In contrast, .NET is designed for rich version support. With side-by-side execution, two or more different versions of the same class can be loaded and executed at the same time. Each application can choose its binding mechanism: whether to bind to a specific version of a class library, the most recent version of the library, or the version in a particular location. In addition, policy can be applied on a machine-by-machine basis to override or further refine version control. This attention to versioning continues into the programming languages. For example, in the C# language, methods are nonvirtual by default, and developers must explicitly declare overridden methods. This means components cannot accidentally break behavior in base classes. C# doesn't require the developer to explicitly declare which exceptions a method can throw: If the exception list changes, client code will still work.

Performance
Where .NET outshines Java is in the ability to fine-tune application behavior and performance. The core application building blocks are designed for scalability and high throughput. For example, with ADO.NET disconnected data access, more data functions can be completed in-memory, which in Java Database Connectivity (JDBC) require a round trip to the database. In addition, the .NET application architecture is designed to be faster. For example, ASP.NET Web pages provide a huge performance improvement over Active Server Pages (ASP), Java Server Page (JSP), and HTML embedded script languages. When compared to the JSP platform, .NET performance is not only better in single-user scenarios, but also in massively multiuser scenarios.

Java is an object-oriented programming language, designed to run across operating system platform, i.e. Unix, Linux, Windows and Mac OS. On the other hand, .Net is a development framework that provides cross-language development, i.e. C++, C# (C Sharp) and Visual Basic but is tied to the Windows

environment. From the corporate side, the advantages of Java are the ability to select hardware and operating platforms regardless of the application. Companies that choose Java will, of course, need programmers that know Java. .Net is more restrictive of the supporting operating system but less restrictive on development resource requirements. A company that chooses .Net may hire developers that possess C++, C# or Visual Basic skills. Java has its own API and framework which is different from .Net's. Java is interpreted, so every instruction in Java is translated on the fly into code for the current platform. .Net compiles and caches methods on the fly so subsequent execution of those methods is as fast as regular native C code. That's the big difference, at the language level, .Net offers a lot more like better generics support that can result in faster code. Java is also portable to just about any platform, but .Net is catching up. The Compact .Net Framework runs on many cell phones and PDAs, the XBOX 360, Mac and Linux. I have a theory that for true platform dependence, Microsoft will drop the System.Windows.Forms namespace and use WPF as the main windowing system, as its much easier to port that to virtually any platform. .Net is basically just for compatibilty on Microsoft stuff, but it makes it so you can COMPILE, and run it quickly. Java, on the other hand, is an interpretter language, that ws designed to run on ANY platform...theoretically, you can run java on an NES, commodore 64, or whatever. Interpretters run dredfully slow, and microsoft tryed making a faster java interpreter witht he creation of j++, but it didnt really catch on. Java and .NET are competing platforms, that's what the difference is. Java's platform is basically focused around a language (Java) and the various application level libraries. .NET is Microsoft's platform. It doesn't enforce any single language, but defines how .NET languages must work. Java's platform exists for all major operating systems, while Microsoft's .NET is only officially supported on Windows. **Both** Java and .NET languages JIT-compile. If you don't believe me, look up the Hotspot compiler. .NET compiles to CIL while Java compiles to it's own intermediate bytecode. It's the same method for both platforms. So perhaps the other answerers would like to explain this whole interpret vs. compile and cache? Oh, and WPF may not necessarily be easier to port. It uses Direct3D for graphical rendering, but uh, Direct3D isn't exactly portable.

Vous aimerez peut-être aussi