Click here to Skip to main content
Click here to Skip to main content

Introduction to Visual J# .NET

, 9 Oct 2001
Rate this:
Please Sign up or sign in to vote.
An overview of the latest Java language tools from Microsoft.
<!-- Main HTML starts here -->

Introduction

Microsoft have released a major piece of the JUMP initiative: Visual J# .NET. This is a set of new tools for those wishing to develop using the java-language syntax. "Java Language Syntax" is the important point here. It is not Java - it's J#.

Visual J# .NET beta 1 can be downloaded from here.

Visual J# .NET beta 1 is fully integrated into Visual Studio .NET beta 2. It can be used to develop applications, class libraries and web services for .NET, and like other .NET languages targets the .NET CLR and uses the base class libraries. As well, J# includes features of other first class languages such as cross language integration, security, versioning and deployment, and debugging and profile support. The J# documentation notes that even if you do not have Visual J# .NET installed on your machine you can still debug your java-language applications.

The new tools include:

  • the J# compiler to convert your java language source code to MSIL
  • A converter to convert java-language bytecode into MSIL (jbimp.exe)
  • Class libraries that provide some of the capabilities of the JDK 1.1.4 packages that were included in Visual J++ 6.0
  • WFC and many of the com.ms.* packages (com.ms.lang, com.ms.dll, com.ms.com, com.ms.win32)

Microsoft is making a very clear distinction between Java - the trademarked technology from Sun - and the java language syntax. Files containing the J# language will have the extension .jsl. This distinction is important because Visual J# .NET does not contain the following functionality:

  • 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 JVM.
  • No support for the Java Native Interface or Remote Method Invocation
  • Support for the sun.io.*, sun.net.*, and netscape.* packages

Upgrading Visual J++ 6.0 projects.

To upgrade Visual J++ 6.0 projects to Visual J# .NET simply open the VJ++ project in the Visual Studio .NET IDE and you will be prompted to have the project upgraded. A new solution file (.jshproj) will be created for your J# project.

There are a couple of issues involved in upgrading such as no support for Pre and post build steps, and version information now being stored in an assembly, and the CLASSPATH feature of VJ++ 6.0 is not supported.

.NET stuff not supported by Visual J#

Java has been compared extensively to C#, but once you get past the familar syntax there are significant differences (see A Comparative Overview of C#). Visual J# does not  support the following features:

  • Syntax support to define properties, events, value types and delegates
  • Syntax for consuming properties and events.
  • Operator overloading
  • Implicit and explicit conversions between types using the op_Implicit and op_Explicit conversion operators.
  • Seamless coercion between java-language data types and .NET Framework data types.

CodeDOM and Visual J#

Visual J# supports the .NET CodeDOM. CodeDOM, or Code Document Object Model, provides a way to describe the structure of a piece of source code that can be rendered in multiple languages. It's used in ASP.NET to render HTML pages, XML Web Service proxies, code wizards, designers etc, or for dynamic compilation.

COM Interop and exposing J# components to COM

COM Interop is supported in much the same was as was done in Visual J++ (ie. using the JActiveX tool) and using J# components from unmanaged clients is achieved by using the RegAsm tool that ships with the .NET SDK. See the online docs for more information.

Hello, World

Obviously no introductory article on J# would be complete without HelloWorld. The code is very similar to what you would write using either C# or VB.NET, though there enough differences to make it clear that this is neither.

package WindowsApplication1;

import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;

//    Summary description for Form1.
public class Form1 extends System.Windows.Forms.Form
{
	private System.Windows.Forms.Button button1;
	//    Required designer variable.
	private System.ComponentModel.Container components = null;

	public Form1()
	{
		//
		// Required for Windows Form Designer support
		//
		InitializeComponent();

		//
		// TODO: Add any constructor code after InitializeComponent call
		//
	}

	// Clean up any resources being used.
	protected void Dispose(boolean disposing)
	{
		if (disposing)
		{
			if (components != null)
			{
				components.Dispose();
			}
		}
		super.Dispose(disposing);
	}

	#region Windows Form Designer generated code
	//    Required method for Designer support - do not modify
	//    the contents of this method with the code editor.
	private void InitializeComponent()
	{
		this.button1 = new System.Windows.Forms.Button();
		this.SuspendLayout();
		// 
		// button1
		// 
		this.button1.set_Location(new System.Drawing.Point(((int)96), ((int)32)));
		this.button1.set_Name("button1");
		this.button1.set_TabIndex(((int)0));
		this.button1.set_Text("Click Me!");
		this.button1.add_Click( new System.EventHandler(this.button1_Click) );
		// 
		// Form1
		// 
		this.set_AutoScaleBaseSize(new System.Drawing.Size(((int)5), ((int)13)));
		this.set_ClientSize(new System.Drawing.Size(((int)272), ((int)93)));
		this.get_Controls().AddRange(new System.Windows.Forms.Control[] {this.button1});
		this.set_Name("Form1");
		this.set_Text("HelloWorld");
		this.ResumeLayout(false);

	}
	#endregion

	// The main entry point for the application.
	/** @attribute System.STAThreadAttribute() */
	public static void main(String[] args) 
	{
		Application.Run(new Form1());
	}

	private void button1_Click (System.Object sender, System.EventArgs e)
	{
		System.Windows.Forms.MessageBox.Show("Hello, World!");
	}
}

 

Visual J# .NET

Visual J# .NET has been designed to allow developers to move from Visual J++ to J# as painlessly as possible. The documentation states "The only new syntax extensions are the keyword ubyte for consuming unsigned bytes and the @attribute directive, which can be used to attach custom attributes to the generated metadata."

Visual J# .NET allows developers to write fully managed .NET applications using the java language syntax, and to move their existing java language applications over to .NET, but is not, one would imagine, the language of choice when developing .NET applications. J# is RAD, is fully managed, and includes CodeDOM support making it suitable for ASP.NET and the designer (unlike the current incarnation of Managed C++) but it lacks support for important .NET features such as properties, value types, delegates and events (unlike MC++ and C#).

Even so, with .NET allowing inter-language operability and COM Interop, J# will allow Java developers wishing to move to .NET the ability to retain a good portion of their legacy java language code while moving forward with .NET development.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Chris Maunder
Founder CodeProject
Canada Canada
Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.
 
His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.
 
He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.
 
Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
GeneralMessageBox/Form Pinmemberskaterkid199029-Sep-07 21:42 
GeneralFilling a ComboBox PinmemberHarold Clements12-Jan-05 3:17 
GeneralIterator Problems Pinmemberharoldjclements21-Oct-04 5:18 
GeneralRe: Iterator Problems PinsussAnonymous26-Nov-04 6:42 
GeneralJ# will allow Java developers wishing to move to .NET PinsussAnonymous10-Aug-04 23:01 
GeneralRe: J# will allow Java developers wishing to move to .NET PinmemberJudah Himango11-Jul-06 17:08 
GeneralReading Empty Cells Pinmemberharoldjclements3-Aug-04 1:25 
GeneralWndproc in j# PinmemberSushi_200032-Dec-03 18:03 
GeneralRe: Wndproc in j# PinmemberLars-Inge Tønnessen27-Feb-04 8:20 
QuestionVisual J# project menu ????? PinsussAnonymous28-Jul-03 15:21 
AnswerRe: Visual J# project menu ????? PinmemberLars-Inge Tønnessen1-Dec-03 13:17 
GeneralJ# filenotfoundexception Pinmemberoggychristie8-Apr-03 2:10 
GeneralRe: J# filenotfoundexception PinsussAnonymous14-May-04 5:51 
GeneralJ# lets us run Java code on .NET PinsussMerill Fernando2-Mar-03 15:17 
GeneralCompatability with Unix PinsussDavid Wade23-Oct-02 4:44 
QuestionJAI (Java Advanced Image) in J#? PinsussAnonymous24-Sep-02 18:15 
AnswerRe: JAI (Java Advanced Image) in J#? PinsussAnonymous26-Sep-02 20:27 
QuestionWhat are you doing ! PinmemberAnonymous24-Oct-01 2:39 
QuestionWhat is the point? PinmemberJarek Gibek10-Oct-01 17:50 
AnswerRe: What is the point? PinmemberChristian Graus10-Oct-01 18:41 
GeneralRe: What is the point? PinmemberSteen Krogsgaard10-Oct-01 21:38 
GeneralRe: What is the point? PinmemberChris Maunder10-Oct-01 21:50 
GeneralRe: What is the point? PinmemberSteen Krogsgaard10-Oct-01 22:55 
GeneralRe: What is the point? PinmemberChris Maunder11-Oct-01 0:28 
GeneralRe: What is the point? PinsussAnonymous7-May-04 0:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 10 Oct 2001
Article Copyright 2001 by Chris Maunder
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid