Where does J# fit in the .NET world?
Takeaway: Microsoft's J# enables Java developers to easily jump from Java to the .NET platform. Take an inside look at J#.
The disputes between Microsoft and Sun Microsystems are famous. These led to the dismissal of Java from the Microsoft platform (but you can still install it as an add-on) and Microsoft dumping its Java clone Visual J++ product.
Microsoft decided to take another approach by luring existing Java developers to the .NET platform. One component of this strategy is the J# programming language. Let's take a closer look at this language and the many associated Microsoft tools.
The Java clone
In late 2001, Microsoft announced its JUMP initiative. The campaign's goal was to enable existing Java developers to easily jump from Java to the .NET platform. J# was a key component in the campaign.
The J# syntax is strikingly similar to Java--it's even identical in many instances. The following code sample contains a simple Java console application for reading the contents of a URL:
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
URL builder = new URL("http://builder.com.com/");
BufferedReader in = new BufferedReader(new
InputStreamReader(builder.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
} }
One amazing aspect of this code is that it compiles with both the Sun Java and .NET J# compilers. This example utilizes base Java packages.
However, you may run into problems when the application gets more complicated. Here's a brief list of what J# doesn't include:
The .NET Framework includes tools for working with your Java/J# code.
J# toolset
The .NET Framework includes the following features to help with J# development:
The J# compiler (vjc.exe) and bytecode converter (jbimp.exe) are located in the .NET Framework installation directory. The default directory path for these files is:
C:\WINNT\Microsoft.NET\Framework\v1.1.4322
J# files are saved with the .jsl file extension, but the compiler doesn't restrict input to only these files. For this reason, you can easily compile a Java source file with it. For example, I compiled the Java sample using the following line:
vjc URLReader.java
The J# compiler contains numerous options that you may utilize with command-line switches. This list contains a sample of these options:
The default compilation output (this may be changed) is an .exe file containing MSIL. This executable may be run from the command line.
Another command-line tool allows you to convert a compiled Java file (bytecode) to its MSIL equivalent. This is useful when the Java source code isn't available.
The command-line is only one option for J# development. The Visual Studio .NET IDE provides full J# support, so it's possible to build a full-featured application (albeit ASP.NET, Windows Forms, command-line, Web service, and so forth) using J#.
J# seems to be a Java clone, but C# has been called this as well. The C# syntax closely resembles both J# and Java.
Another avenue
C# provides another approach for Java developers wanting to jump into .NET development. Microsoft offers the Java Language Conversion Assistant (JLCA). It's a tool that converts Java code into C# for developers who want to move existing applications to the .NET Framework. It provides a quick, low-cost method of converting Java-language applications to C#. The current version is 3.0 beta, and it offers the following features:
It's fully integrated with Visual Studio .NET, so the developer doesn't have to leave the comforts of the IDE to perform the conversion. The JLCA helps you leverage existing investments, thus avoiding some of the risks of new development and decreasing your time to market. Once the conversion is complete, you can immediately begin using the power of the .NET Framework and the component-oriented programming to extend the code.
Here's a quick example of the conversion. The following Java code is used as the input:
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!"); //Display the string.
} }
The C# produced by JCLA follows:
using System;
public class HelloWorld {
[STAThread]
public static void Main(System.String[] args) {
System.Console.Out.WriteLine("Hello World!");
} }
TechRepublic's free .NET newsletter, delivered each Wednesday, contains useful tips and coding examples on topics such as Web services, ASP.NET, ADO.NET, and Visual Studio .NET. Automatically sign up today!
Print/View all Posts Comments on this article
|
|
|
|
|
|
|
|
|
|
|
|
White Papers, Webcasts, and Downloads
- The Impact of Virtualization Software on Operating Environments VMware Today's use of virtualization technology allows IT professionals to ... Download Now
- Five Steps to Determine When to Virtualize YourServers VMware Thinking of virtualizing the servers at your company? Use this step-by-step guide to determine when's the best time to make your big move. Download Now
- VMware Infrastructure: A Guide to Bottom-Line Benefits VMware Frustrated by the high cost of maintaining or building ever-larger data centers? Get the facts you need to formulate your Virtualization Action Plan. Download Now
- Building the Virtualized Enterprise with VMware Infrastructure VMware This paper explains how adopting a virtual infrastructure -- comprised of server, storage, and networking virtualization technologies -- can help your organization build a sustainable competitive ... Download Now
- Building the Virtualized Enterprise with VMware Iinfrastructure VMware VMware virtualization software has been adopted by over 120,000 enterprise ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET





