microsoft visual j net tony goodhew product manager visual j net microsoft corporation n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Microsoft Visual J# .NET Tony Goodhew Product Manager Visual J# .NET Microsoft Corporation PowerPoint Presentation
Download Presentation
Microsoft Visual J# .NET Tony Goodhew Product Manager Visual J# .NET Microsoft Corporation

Loading in 2 Seconds...

play fullscreen
1 / 55

Microsoft Visual J# .NET Tony Goodhew Product Manager Visual J# .NET Microsoft Corporation - PowerPoint PPT Presentation


  • 846 Views
  • Uploaded on

Microsoft Visual J# .NET Tony Goodhew Product Manager Visual J# .NET Microsoft Corporation. Product Goals. Provide a Java language for the Microsoft® .NET Bring the power and richness of the .NET Frameworks to programmers using Java Carry forward existing skill and code investments

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Microsoft Visual J# .NET Tony Goodhew Product Manager Visual J# .NET Microsoft Corporation' - albert


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
product goals
Product Goals
  • Provide a Java language for the Microsoft® .NET
    • Bring the power and richness of the .NET Frameworks to programmers using Java
    • Carry forward existing skill and code investments
  • Seamless upgrade path for Visual J++® developers
  • Full integration with Visual Studio® .NET
net framework

Visual Studio .NET

VB

C++

C#

JScript

J#

Common Language Specification

ASP.NET

Web Forms Web Services

Windows

Forms

ADO.NET and XML

Base Class Library

Common Language Runtime

Operating System

.NET Framework
visual j net

J# Compiler

J# IDE in VS

Visual Studio.NET

JBIMP

J# Class Libraries (JDK Subset)

COM Inter-op

and WFC

.NET Frameworks

(ADO.NET, ASP.NET, Windows Forms, Web Services …)

Common Language Runtime

Operating System

Visual J# .NET
technology overview
Technology Overview
  • Java language
    • Microsoft Visual J#™ .NET compiler
    • Support for .NET CLS
    • Properties, events, and delegates
  • Class libraries
    • Subset of JDK 1.1.4 class libraries
      • Base libraries, collection classes
      • AWT, JDBC, Beans
    • Visual J++ support: Java/COM, J/Direct, WFC
technology overview 2
Technology Overview (2)
  • Binary converter
    • Class files to .NET assemblies
  • Full access to the .NET Framework
    • ASP.NET, ADO.NET, Windows Forms, and so forth
  • Integrated with Visual Studio .NET
    • IntelliSense®, designers, debugger
    • Usability improvements
visual j net compiler
Visual J# .NET Compiler
  • Compiles Java-language sources to Microsoft intermediate language (MSIL)
  • Supports all key features of the Java language
  • Fully supports consuming .NET Framework
  • Preserves Java language, scoping, and class hierarchy semantics
  • Supports extensions in Visual J++
    • J/Direct
    • Attributes
compiler language support
CompilerLanguage Support
  • Classes
    • Inner classes, nested classes, anonymous classes, local classes
  • Throws clause and checked exceptions
  • Static initializer blocks, synchronized blocks
  • .NET CLS compliance
    • Full CLS consumer
    • Limited CLS extender
compiler cls consumer
Compiler CLS Consumer
  • Natural Java-language syntax for accessing
    • Properties – through property accessor methods
    • Delegates – permits creation of delegates over any Visual J# method
    • Events – through event accessor methods
  • Enums
  • Value types
  • Attaching attributes
consuming net meta data
Consuming .NET Meta Data
  • Properties – use property accessors

form.set_Text(“Hello”);

form.get_Text();

  • Delegates – just create the delegate over a Visual J# method

myHandler = new EventHandler(OnClickOK);

  • Events – use event accessors

okButton.add_Click(myHandler);

okButton.remove_Click(myHandler);

consuming net meta data value types and enums
Consuming .NET Meta Data Value Types and Enums
  • Using value types
    • Automatic boxing and unboxing

DateTime dt = new DateTime();

dt = DateTime.Parse(“01/01/2002 12:00”);

System.Object obj = dt; // This boxes value type dt

DateTime dt2 = (DateTime) obj; // This unboxes obj

  • Using enums
    • Casting to underlying primitive type

int iStyle = (int) AnchorStyle.Left;

AnchorStyle style = (AnchorSytle) iStyle;

    • Using bitwise operations

AnchorStyles style = AnchorStyle.Left | AnchorStyle.Bottom;

attaching net attributes
Attaching .NET Attributes
  • Attribute suffix is optional
  • @attribute

/** @attribute WebMethodAttribute(true) */

String GetStockQuote(String symbol)

  • @attribute.method

/** @property */

/** @attribute Description(“Property Size”) */

/** @attribute.method Description(“Get accessor”) */

int get_Size() { return 0; }

  • @attribute.return

/** @attribute.return MarshalAs(UnmanagedType.BSTR) */

System.String getString();

  • @assembly

/** @assembly AssemblyVersion(“1.*”) */

using other net primitive types
Using Other .NET Primitive Types
  • ubyte

ubyte [] bytes = new ubyte[100];

File.Read(bytes);

  • Unsigned types not in Visual J#

System.UInt32 uint = (System.UInt32) 100;

  • Managed pointer type

System.IntPtr intPtr = System.IntPtr.Zero; // null

  • Boxing and unboxing of primitive types

System.Object obj = 10; // Won’t work

// Will work and will box the integer 10 to a Sysem.Object.

System.Object obj = (System.Int32)10;

int j = (int)(System.Int32) obj; // Unbox

code sample for intptr
Code Sample for IntPtr

import System.Runtime.InteropServices.*;

public class A {

      public static void main(String [] args) {

      byte [] barray = new byte[20];

      GCHandle gch = GCHandle.Alloc(barray, GCHandleType.Pinned);

      System.IntPtr iptr = gch.AddrOfPinnedObject();

      test(iptr);

      }

      /** @attribute DllImport(“sample.dll") */

      static native void test (System.IntPtr iptr);

}

using delegates
Using Delegates

J# class:

 class Consumer {

      public static void main()  {

      CreateDelegate del = new CreateDelegate();

      // Consume the .NET Delegate in J#

      del.myD.Invoke();

   }

}

C# class:

using System;

public class CreateDelegate  {

   // Declare a delegate for a method that takes no params and returns void

   public delegate void myDelegate();

   // Define a method to which the delegate can point

   public void myMethod()  {

       Console.WriteLine("Delegate called");

   }

   public CreateDelegate() {

            // Create a delegate for above method

            myD = new myDelegate(myMethod);

   }

    public myDelegate myD;

}

code sample for boxing primitives
Code Sample for Boxing Primitives

int i = 10;

System.Object obj = (System.Int32) i;

// Boxes i to an object

int j = (int)(System.Int32) obj;

// Unboxes obj to an integer

compiler cls extender
Compiler CLS Extender
  • Supports authoring .NET properties, events, and delegates
    • No new keywords: uses @ directives to mark members as properties, events, delegates
    • Accessor methods follow CLS naming conventions (get_, set_, add_, remove_)
  • Can be consumed from other languages
  • No support for enums or value types
  • In Beta 2, use the /extender option
authoring properties
Authoring Properties

// A property ‘Size’ of type int

/** @property */

public int get_Size(){…}

/** @property */

public void set_Size(int size){…}

// An indexed property ‘Item’ of type

// System.Object; the index type is a string

/** @property */

public System.Object get_Item(System.String key){…};

/** @property */

public void set_Item(System.String key, System.Object value){…}

authoring events and delegates
Authoring Events And Delegates

// Creates an Event called PropertyChanged

// PropertyChangedEventHandler is the handler,

// (a delegate)

/** @delegate */

delegate void PropertyChangedEventHandler();

/** @event */

void add_PropertyChanged(PropertyChangedEventHandler eventHandler){…}

/** @event */

void remove_PropertyChanged(PropertyChangedEventHandler eventHandler){…}

object and string in visual j
Object and String in Visual J#
  • Base objects (object, string, exception)
    • Seamless mapping
    • All semantics are maintained
    • Cross-language Interop automatically maps these object types
    • java.lang.Object(JLO) can be used instead of System.Object to access .NET Frameworks
    • java.lang.String(JLS) is exposed as ‘string’ data type in MSIL
using net framework
Using .NET Framework
  • Strings
    • Auto marshaling of Java String and .NET Strings

System.String hello = “Hello”;

String helloJava = hello;

  • Calling methods that take by ref parameters

String str = “Hello”

callMethodThatAppendsWorld(str); // by ref parameter

Console.WriteLine(str); // prints “Hello World”

  • Getting the System.Type for a class

class sampleClass = Sample.class;

System.Type sampleType = Sample.class.ToType();

// Calling sampleClass.ToType() will be slower

using net framework 2
Using .NET Framework (2)
  • Keywords as identifiers – use @<keyword>

class @class {} // class defined in J#

int i = obj.@synchronized // accessing field named synchronized

  • Signing assemblies

/** @assembly AssemblyKeyFile(“key.snk”) */

  • Declarative security

/** @attribute FileIOPermission(SecurityAction.Demand) */

ReadFile();

// demands for the permission before allowing

// the call

binary converter class byte code to msil

Java-byte-code class file

(.class, .jar, .zip)

Java-language source file

(newcode.jsl)

.NET Framework

JBIMP

Binary Converter

VJC

J# .NET Compiler

Subset of JDK Class Libraries

.NET Assembly (MSIL)

convclass.dll

.NET Assembly (MSIL)

newcode.dll

.NET Framework Common Language Runtime

Win32

Binary Converter .Class (Byte-Code) to MSIL
binary converter jbimp
Binary Converter (JbImp)
  • Converts .class files to MSIL
  • Reports unresolved references
    • And permits you to automatically find them
    • /usestubrefs option
      • Creates stub types for unresolved references
      • Useful for unused unresolved references
  • J/Direct
  • Supports archive files - zip/jar/cab format
  • Signed assemblies
    • Use /keyfile, /keycontainer, /delaysign
class libraries jdk subset
Class LibrariesJDK Subset
  • Visual J# Redistributable includes subset of JDK 1.1.4 class libraries in MSIL
    • JNI and RMI are not supported
  • Key functional areas are:
    • Base libraries
      • (lang, util, math, io, net, text, ...)
    • AWT
    • JDBC
    • Beans
    • Collection APIs (AP subset)
      • Set, Map, List, Collection, and so forth
visual j style java com interop
Visual J++ Style Java-COM Interop
  • Visual J# supports most key Java/COM Interop scenarios of Visual J++
    • Applications using COM components
      • @com.class, @com.interface, @com.method, and so forth
    • Applications hosting Microsoft ActiveX® controls
    • Exposing components to COM
      • Must have @com.register
visual j style java com interop 2
Visual J++ Style Java-COM Interop (2)
  • Support for this is layered on .NET Framework COM Interop
  • In most cases, existing Visual J++ applications using Java/COM will not need any changes to run
  • The Upgrade Wizard fully automates all steps of the upgrade
  • Newly written Visual J# applications must directly target .NET Framework COM Interop semantics and tools
slide28
WFC
  • WFC is supported in Visual J#
    • Existing Visual J++ WFC applications
    • Hosting of WFC controls
    • No source code changes required
  • New Visual J# applications must target Windows Forms instead
integration with visual studio net
Integration with Visual Studio .NET
  • Full integration in the Visual Studio shell
    • Project system
      • Editor, Solution Explorer
      • Compile/build, execute/debug
      • Project wizards
    • Language services
      • Designers – Web Forms, Windows Forms, XML Web Services
      • IntelliSense, Colorizer
  • Debugger
    • Java-language exceptions
    • Java-language expression evaluator
visual studio net power
Visual Studio .NET Power
  • Well integrated designers for rapid application development
    • Using HTML, Data, XML, server-side components
  • End-to-end application debugging support
    • Web applications
    • Cross language
    • Across processes, machines, and stored procedures
  • Customizable and extensible IDE components
    • Using macros
visual studio net power 2
Visual Studio .NET Power (2)
  • Deployment support for packaging and installation
    • Deployment projects
    • Merge modules, setup, Web setup
  • International-ready application development
    • Localization projects, localized setup projects
    • Resource files with full unicode support
environment tips and tricks
Environment Tips and Tricks
  • Solution Explorer
  • IntelliSense
  • Class view
  • Object browser
  • Outlining
  • Toolbox
  • Command window
  • Displaying miscellaneous files
  • Task list
productivity
Productivity
  • Dynamic Help
  • Microsoft Visual SourceSafe® Integration
  • Automating the build process
    • Command-line switches
    • Build macros
  • Batch builds
  • Command-line tools
    • VJC – Visual J# command-line compiler
    • JBIMP – Java byte-code to MSIL converter
debugging
Debugging
  • Cross language
    • .NET, Unmanaged, ASP, SQL
  • Cross process and machine
  • Rich debugger automation
  • Windows
    • Autos, Locals, Watch, Memory, Call Stack
  • Exceptions dialog
  • Expand your types automatically
    • Vjsee.dat
visual j redistributable package
Visual J# Redistributable Package
  • Installs on .NET Redist
  • Complete runtime for deployment of Visual J# applications
    • Compiler
    • Class libraries
  • Deployment support for packaging
net power in visual j common language runtime
.NET Power in Visual J# –Common Language Runtime
  • Version aware assemblies
  • Cross language Interop
  • Native code Interop (PInvoke)
  • COM Interop
net power in visual j frameworks
.NET Power in Visual J# – Frameworks
  • ADO.NET
    • XML/relational views, in-memory cache
  • ASP.NET
    • Authoring controls in Visual J#,
    • Data binding using ADO.NET and XML
    • Multiple client support
net power in visual j frameworks 2
.NET Power in Visual J# – Frameworks (2)
  • Web Services
    • Proxy generation, UDDI integration
    • Support for HTTP – GET, POST, and SOAP wire formats
  • Windows Forms
    • Performance, GDI+, rich platform integration
    • Controls can be hosted in Internet Explorer 5.x
native interop using pinvoke
Native Interop Using PInvoke
  • Use .NET PInvoke attributes
    • DllImportAttribute, MarshalAsAttribute, StructLayoutAttribute, and so forth

/** @attribute DllImport("USER32") */static native int MessageBox(

int hwndOwner,

System.String text,

System.String title,

int MyStyle);

net com interop
.NET COM Interop
  • Supports native .NET Framework semantics for COM Interop
    • Newly written Visual J# applications must directly target .NET Framework COM Interop semantics and tools
      • Tools: TlbImp, AxImp, TlbExp, RegAsm
      • Attributes and classes in System.Runtime.InteropServices package
    • Visual J# enables all scenarios that are supported by other languages on .NET Framework
      • For example:
        • Using COM or ActiveX controls
        • Exposing WinForms components as ActiveX controls
web control authoring
Web Control Authoring

VJSControl.ascx file:

<%@ Control Language="VJ#" AutoEventWireup="false" Codebehind=“VJSControl.ascx.jsl" Inherits="WebApplication1.VJSControl"%>

Codebehind file:

// VJSControl.ascx.jsl

public abstract class VJSControl extends System.Web.UI.UserControl {

private System.String customername = "";

/**@property*/

public System.String get_customerName() {

return customername;

}

/**@property*/

public void set_customerName(System.String s) {

customername = s;

}

}

web control authoring 2
Web Control Authoring (2)

Using a Web Control in a Web Forms page:

<%@ Page language="VJ#" Codebehind="WebForm1.aspx.jsl" AutoEventWireup="false" Inherits="VJSWebApp.WebForm1" %>

<%@ Register TagPrefix="uc1" TagName="VJSControl" Src="VJSControl.ascx" %>

...

<uc1:VJSControl id="VJSControl1" customerName="Thomas" runat="server">

</uc1:VJSControl>

data binding in web applications
Data Binding in Web Applications

<%@ Page language="VJ#" Codebehind="WebForm1.aspx.jsl" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>

...

<asp:DataGrid id="DataGrid1" runat="server" DataSource='<%# DataBinder.Eval(dataSet11, "get_Tables().get_Item(Customers).

get_DefaultView()") %>'>

</asp:DataGrid>

web service proxy generation
Web Service Proxy Generation

<%@ WebService Language="VJ#" Class="VJSWS1.Service1" %>

Package VJSWS1;

...

public class Service1 extends System.Web.Services.WebService

{

/** @attribute WebMethod() */

public int AddOne(int x)

{

return x+1;

}

}

proxy generation
Proxy Generation

Command line for proxy generation:

wsdl.exe /l:"Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" http://localhost/VJSWS1/Service1.asmx

Generated File:

// Service1.jsl

public class Service1 extends System.Web.Services.Protocols.SoapHttpClientProtocol {

...

/** @attribute System.Web.Services.Protocols.SoapDocumentMethodAttribute(...)*/

public int AddOne(int x) {

System.Object[] results = this.Invoke(("AddOne").ToString (), new System.Object[] {(System.Int32)x});

return ((int)(System.Int32)(results[0]));

}

...

upgrading from visual j visual j to visual j
Upgrading from Visual J++ Visual J++ to Visual J#
  • Upgrading is as simple as pressing F5 in most cases
  • Upgrade Wizard in IDE
    • Opens Visual J++ solutions and projects
    • Automatically detects missing references
      • Class files – and locates them if present
      • COM references – runs Tlbimp and adds managed wrapper
    • Upgrade Report lists issues with prescriptive links
  • JBIMP to convert class files to MSIL
j direct
J/Direct
  • Visual J# compiler fully supports J/Direct
    • @dll.import, @dll.struct, @dll.structmap
    • Callbacks
  • All existing Visual J++ applications using J/Direct can be compiled and run without change
  • Binary Converter (JbImp) supports converting classes that use J/Direct
  • The com.ms.dll and com.ms.win32 packages used with J/Direct are fully supported
upgrading visual j projects using java com calling com from java
Upgrading Visual J++ Projects Using Java/COM – Calling COM from Java
  • Two simple steps:
    • Generate managed wrappers for the type library of the COM component using TlbImp tool

TlbImp COMComponent.tlb

    • Compile the Visual J++ application together with the JActiveX wrappers, referencing the managed wrapper generated by TlbImp

vjc <AppSources> <JActiveXWrappers> /reference:managedWrappers

  • Full debugging support
upgrading visual j projects using java com calling java from com
Upgrading Visual J++ ProjectsUsing Java/COM – Calling Java from COM
  • As simple as recompiling the Visual J++ component and registering it!!
  • For components implementing JActiveX templates (/c2j option):
    • Generate managed wrappers for the type library of the COM component using the TlbImp tool

TlbImp COMComponent.tlb

    • Compile the VJ++ component while referencing the managed wrapper generated by Tlbimp

vjc <AppSources> /reference:ManagedWrappers

    • Register the component using the RegAsm tool
  • COM clients are transparent to the fact that the Visual J++ component is now hosted in the common language runtime
unsupported visual j java com features
Unsupported Visual J++ Java/COM Features
  • Custom marshaling
  • Monikers
  • Exposing components to COM as ActiveX controls
  • Exposing components to COM that do not have the @com.register attribute
  • Conversion of class files that use Java/COM
upgrading wfc applications
Upgrading WFC Applications
  • Vjswfc.dll must be added as an explicit reference during command-line compilation
    • vjc /r:vjswfc.dll Form1.java
  • <Object> tag format for WFC HTML controls modified

<OBJECT CLASSID="CLSID:CF83EA5E-0FFD-4476-9BF7-6C15F7F8BDCF"

height=20 width=30 ... VIEWASTEXT>

<PARAM NAME=CODECLASS VALUE=MyHTML.dll#Class1>

<PARAM NAME=VJSVERSION VALUE=VJ# Version>

</OBJECT>

  • User HTML control class has to be compiled into a managed assembly
  • No designer support in Visual J# IDE for WFC projects
other upgrade issues
Other Upgrade Issues
  • If you use RMI:
    • You may use Web Services
  • If you use JNI:
    • Use P/Invoke or J/Direct
  • If you use com.ms.* that is unsupported (such as mtx, xml):
    • Use the corresponding .NET Frameworks (equivalent or better)
availability
Availability
  • Beta 1 shipped on October 10, 2001
  • Beta 2 shipped on March 19, 2002
    • Add-on to Visual Studio .NET RTM/SP1
    • Available for download from MSDN

http://msdn.microsoft.com/visualj/jsharp/beta.asp

    • Visual J# .NET Redist only version of Beta 2 also available for download
  • Localized versions
  • Final product availability
    • Mid-2002
    • Coupon in Visual Studio .NET boxes
additional resources
Additional Resources
  • Community sites

http://www.gotdotnet.com/team/java

  • Visual J# .NET newsgroup

microsoft.public.dotnet.vjsharp

slide55
Thank you for joining us for today’s Microsoft Support

WebCast.

For information about all upcoming Support WebCasts

and access to the archived content (streaming media

files, PowerPoint® slides, and transcripts), please visit:

http://support.microsoft.com/webcasts/

We sincerely appreciate your feedback. Please send any

comments or suggestions regarding the Support

WebCasts to supweb@microsoft.com.