Chapter 2. Comparing Java and .NET Technologies

Chapter 1, presented a high-level introduction to Microsoft .NET, comparing it both conceptually and technologically with Java. This chapter extends that discussion but focuses more deeply on the technology provided by the two platforms.

Note

Although this book focuses predominantly on the .NET functionality that is directly comparable to that of Java 2 Standard Edition (J2SE) version 1.4, this chapter also covers functionality provided by Java 2 Enterprise Edition (J2EE) version 1.3.1. Many Java programmers work with both J2SE and J2EE, and although .NET has a ways to go before it competes with J2EE, it’s useful to demonstrate the current features that are comparable and the alternative technologies to use where there are gaps. We don’t discuss APIs that aren’t part of J2SE and J2EE: they provide compelling and interesting functionality, but it’s simply not possible to cover every Java API, and it’s often difficult to make substantive comparisons. This is true even for the new Java XML APIs. Although they will help to address the imbalance between the XML capabilities of Java and those of .NET, at the time of this writing they are still in early access release. Also, we haven’t included a comparison of Java 2 Micro Edition (J2ME) and the Microsoft .NET Compact Framework. Each is important to the Sun and Microsoft consumer device strategies, but they are topics deserving of their own books.

When viewed holistically, the Java and .NET platforms are comparable: both provide solutions to most contemporary business computing issues. However, when the platforms are broken down into functional components, mapping between the constituent parts is often very loose.

The .NET class library doesn’t yet encompass all the functionality found in the J2EE class libraries and often needs to utilize other Microsoft technologies to provide a complete solution; we expect that these technologies will become more tightly integrated as the .NET platform matures.

Despite these inconsistencies, we proceed with a liberal attitude, presenting technology alternatives that are accessible from the .NET platform even though they are not explicitly part of it.

Note

Namespaces are the mechanism used to provide categorization and structure in the .NET class libraries. We discuss namespaces in Chapter 4, but for now it’s enough to understand that namespaces are analogous to Java packages.

Java 2 Platform, Standard Edition

Table 2-1 shows .NET technology alternatives to the major components of the J2SE platform as broken down within the J2SE platform documentation.

Table 2-1. Comparison of Java 2 Standard Edition and .NET

Java

.NET

Core APIs

 

Lang and Util

The .NET class libraries contain functionality that is broadly comparable to the Java Lang and Util APIs. However, the diverse nature of the functionality in these two APIs makes it impossible to provide a useful high-level functionality mapping. For more information, see Appendix F, which provides a class-level mapping between the Java and .NET class libraries.

New I/O

The New I/O API is a collection of features and performance improvements new to J2SE version 1.4. Many of these features provide functionality that is already available in .NET, including regular expressions, asynchronous I/O, and character encoding. In .NET, asynchronous I/O capabilities are incorporated directly into the standard networking and Stream classes. Both Chapter 10, and Chapter 14, provide details of the asynchronous I/O capabilities provided by the .NET classes. Regular expressions and character encoding are both covered in Chapter 7.

Networking

The System.Net namespace of the .NET class library contains functionality comparable to that of the Java networking classes. Consult Chapter 14 for complete details.

Preferences

Along with the Microsoft Windows registry, .NET provides a mechanism called isolated storage. Together, these features provide the technology that is most comparable to the Java Preferences API. We discuss isolated storage in Chapter 10 and discuss the Windows registry in Appendix A.

Collections Framework

The System.Collections namespace of the .NET class library includes functionality comparable to the Java Collections Framework. Chapter 9, provides a detailed discussion of .NET collections.

Java Native Interface (JNI)

JNI provides access to platform-specific functionality from the platformneutral environment provided by Java. As a Windows-based environment, .NET doesn’t face these issues. However, .NET does provide the Platform Invocation Service (PInvoke), which allows calls to functions contained in unmanaged libraries. .NET also includes extensive capabilities for interoperability with COM components.

Security

The .NET Framework provides a comprehensive security system, which can be used to grant or deny platform features to applications. Chapter 17, provides a discussion of the .NET security system.

Java API for XML Processing (JAXP)

XML processing capabilities are built deeply into the .NET class libraries, and many individual classes are XML-aware. The functionality that compares most directly with JAXP is contained in the System.Xml and System.Xml.Xsl namespaces. Chapter 11, contains a detailed description of these facilities.

Logging

The .NET Framework doesn’t provide a generic logging mechanism equivalent to the Java Logging API. Instead, Logging in .NET uses the Windows Event Log, which we discuss in Appendix A.

JavaBeans

.NET doesn’t provide a technology that is directly comparable to JavaBeans. Some of the property and introspection capabilities of JavaBeans are built directly into the .NET languages and the class library. From a visual component perspective, .NET includes a component model based on implementation of the System.ComponentModel.IComponent interface.

Locale Support

.NET provides extensive support for localization of applications. Much of this functionality is contained in the System.Globalization namespace.

Integration APIs

 

Remote Method Invocation (RMI)

The .NET Framework includes the remoting system, which is a functional equivalent of RMI. Chapter 15, details the remoting system.

JDBC

A subsection of the .NET class library below the System.Data namespace and commonly referred to as ADO.NET provides functionality comparable to that of JDBC. Chapter 16, provides a complete description.

Java Naming and Directory Interface (JNDI)

Classes contained in the System.DirectoryServices namespace provide access to Active Directory, NDS, and LDAP directory servers.

CORBA

The .NET platform does not provide support for CORBA integration.

UI Toolkits

 

Abstract Windows Toolkit (AWT) and Swing

The .NET Framework includes a UI toolkit known as Windows Forms. Although less flexible and less complete than the Java alternatives, Windows Forms allow the programmer to develop applications for the Windows platform. Chapter 18, contains an overview of the Windows Forms toolkit.

Java 2D

Windows GDI+, exposed through classes in the .NET class library, is the functional equivalent of the Java 2D API. Chapter 18 contains an overview of GDI+.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset