Where does J# fit in the .NET world? - Windows Server - Techguide

Where does J# fit in the .NET world?

 

Summary

J# is Microsoft's approach to lure existing Java developers to the .NET platform. Is it the answer for the Java programmer who wants to work on the Windows platform?

Events

Echelon 2012
June 11 and 12, 2012

University Cultural Centre, National University of Singapore

Startup Asia Jakarta 2012
June 7 and 8, 2012

12th Floor, Annex Building, Wisma Nusantara Complex, Jl. M.H. Thamrin No. 59 Jakarta 10350, Indonesia

MMA Forum Singapore
April 23-25, 2012

Grand Hyatt Singapore

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 utilises 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 ability to create class bytecode files.
  • The ability to develop Java applets for browsers.
  • The ability to create applications that will run in a Java Virtual Machine (JVM).
  • Java Native Interface or Remote Method Invocation (RMI) support.
  • Support for the sun.io.*, sun.net.*, and netscape.* packages.

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:

  • J# compiler to convert your Java language source code to Microsoft intermediate language (MSIL)
  • A converter to convert Java-language bytecode into MSIL
  • Class libraries that provide some of the capabilities of the JDK 1.1.4 packages that are in Visual J++ 6.0 (Visit Microsoft's site for a more detailed explanation of what packages/classes are supported.)
  • WFC and many of the com.ms.* packages (com.ms.lang, com.ms.dll, com.ms.com, com.ms.win32).

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 utilise with command-line switches. This list contains a sample of these options:

  • /o--enable compiler optimisation
  • /debug--emit debugging information
  • /help--display help and description of available command-line options
  • /out--write compiled output to specified file

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:

  • The conversion of J2EE 1.3 and JDK 1.3 libraries, as well as Enterprise Java Beans, Java Authentication and Authorization Service, Java Cryptography Extension, Java Message Service, Java Naming and Directory Interface, and RMI.
  • Deep support for migrating SWING applications.
  • JavaServer Pages (JSP) and servlet application conversion.

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!");
} }

Is it being used?
As a certified Java developer, I made the move to .NET with C#. When discussing .NET development, the conversation usually focuses on either VB.NET, C#, or both; I rarely hear others talking about the J# language. This leads me to question if it's being fully embraced, or is C# the predominant choice for Java developers? Let us know what you think.

Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

ZDNet Asia Live

Malaysia organizations don't realize severity of cyberattacks http://t.co/PUCv68Rd

News: Radio Costa Rica by EnjoyIT 1.0: Radio Costa Rica allows you to listen to a great var... http://t.co/BLzVT5As http://t.co/1Dhcy6ki

The key for mobile operators is identifying the applications that are popular with subscribers on their network. They can then work partn...

2 hours ago by camcullen on Experience trumps content in apps monetization

Experience trumps content in apps monetization | ZDNet http://t.co/gBXcjbGd

Experience trumps content in apps monetization - ZDNet Asia News: "What we are doing currently is not to monetiz... http://t.co/S2EZtd8m

Malaysia organizations don't realize severity of cyberattacks: "Minister Maximus Johnity Ongkili said at the Sec... http://t.co/bgVlOBvx

#security Malaysia organizations don't realize severity of cyberattacks: "Minister Maximus Johnity Ongkili said ... http://t.co/hkFb4zrI

Malaysia organizations don't realize severity of cyberattacks http://t.co/EEEmRM3j via @zdnetasia

Malaysia organizations don't realize severity of cyberattacks - ZDNet Asia News http://t.co/YpNMYgb5

Malaysia organizations don't realize severity of cyberattacks http://t.co/FFems54Q

China solar cell makers seek Taiwan partnerships http://t.co/p5Hh7kJD

Big data acquisitions pave way to fast, effective innovation http://t.co/hdiEfBsz via @zdnetasia

Integration, focused investments to propel Windows Phone: By Kevin Kwang , ZDNet Asia on May 23, 2012 (2 hours a... http://t.co/E7tsZbHJ

Integration, focused investments to propel Windows Phone http://t.co/u9TqjQ8C

ZDNet Asia IT Salary Benchmark 2012 http://t.co/rVwYlV7H

AsiaClassifiedToday. Integration, focused investments to propel Windows Phone - ZDNet Asia: S... http://t.co/47tdjZyG #asia #google #biz

So much as we know , MTK6575 extremely integrated frequency1GHz ARM Cortex-A9 processor, the superiority of 3G / HSPA Modem, and help the...

1 day ago by y15822137359 on 5 SaaS adoption speed bumps to avoid

I reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...

2 days ago by wykoong on Gartner: Mobile CRM gives better ROI than social

This video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...

3 days ago by TradeBrother on A quick fill handle trick for Microsoft Excel

waiting...

5 days ago by eapete on What should count in a company's market value?

Boy, you've opened a can of worms now.

Wait for the rants & raves.

5 days ago by eapete on What should count in a company's market value?

I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...

5 days ago by wykoong on Drop the egos, copy ideas, then innovate