Click here to Skip to main content
15,879,490 members
Articles / Operating Systems / Windows
Article

Introduction to Visual J# .NET

Rate me:
Please Sign up or sign in to vote.
2.75/5 (7 votes)
9 Oct 2001CPOL4 min read 283.9K   14   37
An overview of the latest Java language tools from Microsoft.

Image 1

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.

Image 2Visual 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

Image 3

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

Image 4

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)


Written By
Founder CodeProject
Canada Canada
Chris Maunder is the co-founder of CodeProject and ContentLab.com, and has been a prominent figure in the software development community for nearly 30 years. Hailing from Australia, Chris has a background in Mathematics, Astrophysics, Environmental Engineering and Defence Research. His programming endeavours span everything from FORTRAN on Super Computers, C++/MFC on Windows, through to to high-load .NET web applications and Python AI applications on everything from macOS to a Raspberry Pi. Chris is a full-stack developer who is as comfortable with SQL as he is with CSS.

In the late 1990s, he and his business partner David Cunningham recognized the need for a platform that would facilitate knowledge-sharing among developers, leading to the establishment of CodeProject.com in 1999. Chris's expertise in programming and his passion for fostering a collaborative environment have played a pivotal role in the success of CodeProject.com. Over the years, the website has grown into a vibrant community where programmers worldwide can connect, exchange ideas, and find solutions to coding challenges. Chris is a prolific contributor to the developer community through his articles and tutorials, and his latest passion project, CodeProject.AI.

In addition to his work with CodeProject.com, Chris co-founded ContentLab and DeveloperMedia, two projects focussed on helping companies make their Software Projects a success. Chris's roles included Product Development, Content Creation, Client Satisfaction and Systems Automation.

Comments and Discussions

 
GeneralMessageBox/Form Pin
skaterkid199029-Sep-07 21:42
skaterkid199029-Sep-07 21:42 
GeneralFilling a ComboBox Pin
Harold Clements12-Jan-05 3:17
Harold Clements12-Jan-05 3:17 
GeneralIterator Problems Pin
haroldjclements21-Oct-04 5:18
haroldjclements21-Oct-04 5:18 
GeneralRe: Iterator Problems Pin
Anonymous26-Nov-04 6:42
Anonymous26-Nov-04 6:42 
GeneralJ# will allow Java developers wishing to move to .NET Pin
Anonymous10-Aug-04 23:01
Anonymous10-Aug-04 23:01 
GeneralRe: J# will allow Java developers wishing to move to .NET Pin
Judah Gabriel Himango11-Jul-06 17:08
sponsorJudah Gabriel Himango11-Jul-06 17:08 
GeneralReading Empty Cells Pin
haroldjclements3-Aug-04 1:25
haroldjclements3-Aug-04 1:25 
I have a problem with reading null value from my database. The connection works and does retrieve the data. However if there is an empty cell in the database it creates an exception “java.lang.classCastException: Specified cast is not valid”

while (myDataReader.Read())<br />
{<br />
	description = myDataReader.GetString(0);<br />
	//The error is here!<br />
	custPN = System.Convert.ToString(myDataReader.GetString(2));<br />
	//custPN = myDataReader.GetString(2);<br />
	sql = "SELECT Name FROM tblSupplier WHERE SupplierID = " + myDataReader.GetInt16(1);<br />
}


I have tried to convert the output to a string, but that did not work. I think that the problem is with the .GetString() line as a blank cell is not a string. This cell is not always empty so .GetString() works fine when it's not.

If anyone could help me I will be eternally grateful


Harold Clements
GeneralWndproc in j# Pin
Member 7431922-Dec-03 18:03
Member 7431922-Dec-03 18:03 
GeneralRe: Wndproc in j# Pin
Lars-Inge Tønnessen27-Feb-04 8:20
Lars-Inge Tønnessen27-Feb-04 8:20 
QuestionVisual J# project menu ????? Pin
Anonymous28-Jul-03 15:21
Anonymous28-Jul-03 15:21 
AnswerRe: Visual J# project menu ????? Pin
Lars-Inge Tønnessen1-Dec-03 13:17
Lars-Inge Tønnessen1-Dec-03 13:17 
GeneralJ# filenotfoundexception Pin
oggychristie8-Apr-03 2:10
oggychristie8-Apr-03 2:10 
GeneralRe: J# filenotfoundexception Pin
Anonymous14-May-04 5:51
Anonymous14-May-04 5:51 
GeneralJ# lets us run Java code on .NET Pin
Member 9391932-Mar-03 15:17
Member 9391932-Mar-03 15:17 
GeneralCompatability with Unix Pin
swade3023-Oct-02 4:44
swade3023-Oct-02 4:44 
QuestionJAI (Java Advanced Image) in J#? Pin
Anonymous24-Sep-02 18:15
Anonymous24-Sep-02 18:15 
AnswerRe: JAI (Java Advanced Image) in J#? Pin
Anonymous26-Sep-02 20:27
Anonymous26-Sep-02 20:27 
QuestionWhat are you doing ! Pin
24-Oct-01 2:39
suss24-Oct-01 2:39 
QuestionWhat is the point? Pin
Jarek G10-Oct-01 17:50
Jarek G10-Oct-01 17:50 
AnswerRe: What is the point? Pin
Christian Graus10-Oct-01 18:41
protectorChristian Graus10-Oct-01 18:41 
GeneralRe: What is the point? Pin
Steen Krogsgaard10-Oct-01 21:38
Steen Krogsgaard10-Oct-01 21:38 
GeneralRe: What is the point? Pin
Chris Maunder10-Oct-01 21:50
cofounderChris Maunder10-Oct-01 21:50 
GeneralRe: What is the point? Pin
Steen Krogsgaard10-Oct-01 22:55
Steen Krogsgaard10-Oct-01 22:55 
GeneralRe: What is the point? Pin
Chris Maunder11-Oct-01 0:28
cofounderChris Maunder11-Oct-01 0:28 
GeneralRe: What is the point? Pin
Anonymous7-May-04 0:17
Anonymous7-May-04 0:17 

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

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