Release Date: 7/5/2004
| Update Date: 7/5/2004
Visual J # .NET team
Microsoft Corporation
Summary: Through Microsoft J # browser controls, developers can migrate the Java applet written on the Java virtual machine to the .NET framework. This article describes the J # browser control to developers and describes the steps to migrate the Java apphaped to the .NET framework. This article also discusses other topics, such as the security and debugging of J # browser controls, as well as unsupported features in the current version.
Download the HTML applet to the object mark converter (95KB)
This article assumes that developers are familiar with .NET framework and Visual J # .NET. To download the J # browser control runtime, see http://msdn.microsoft.com/vjsharp/downloads/browsercontrols/.
This page
Introduction New features Compile the Java applet to the J # Browser control to update the HTML page to deploy the J # browser control to use the J # Browser controls to run the J # Browser control on the user's computer.
Introduction
The Java apps that have been migrated to the .NET framework using Visual J # .NET, called J # Browser Controls. J # Browser Controls are designed to allow customers to migrate their existing Java applet to the .NET framework.
The JAVA applet has a similar runtime behavior with the original Java applet and retains Java language semantics. If the J # browser control running library is installed on your computer, users may even know that the specific Web site has been upgraded to the J # browser control.
To migrate a Java applet to a J # browser control, you must install the Visual J # .NET version 1.1 re-release package and .NET Framework SDK version 1.1 or Visual Studio .NET 2003. Similarly, if the user wants to run the J # browser controls that are carried by the Web site, you must install the .NET Framework 1.1 version of the package and J # browser control running on your computer. J # Browser Controls cannot run on the Java virtual machine. The J # browser control can only be run in Microsoft Internet Explorer (version 5.1 and later).
The process of migrating the Java applet to the J # browser control includes three steps:
1. Use the Visual J # compiler to compile the Java applet as a J # browser control. 2. Update the HTML page to use the J # browser control instead of using the Java applet. 3. Copy the J # browser control and HTML page to the web server.
Back to top
new features
The following features have been added in the J # browser control 1.1B:
Offline support
Microsoft J # Browser Control 1.1B now supports loading controls in Internet Explorer without web servers. Currently support the following schemes:
• Load controls from local file systems • Load controls from network drive • Load controls from network drive
In all schemes described above, the J # browser control will run through intranet privileges by default.
Script support
Microsoft J # Browser Control 1.1B supports the following script solutions.
• Script calls the J # browser control and access its properties • Call script events from J # Browser Controls • J # Browser Controls Use the Netscape JavaScript API to access elements in the web page published by the Internet Explorer object model.
The J # Browser Control 1.1B also provides full support to the Netscape JavaScript API function. Netscape.javascript applet API software package has the following classes:
• Netscape.javaScript.jsbobject • Netscape.javascript.jsexception Back to top
Compile the Java applet to a J # browser control
You can use the Visual J # compiler (VJC.exe) to compile the Java applet as a managed library, thereby migrating them to the J # browser control. You can also compile Java Small Source Codes as J # Browser Controls from the command prompt. If the Java applet is developed using Microsoft Visual J 6.0, it may only be upgraded to Visual J # .NET using Visual Studio .NET.
Compiling the Java applet to a managed library similar to compiling any other library in Visual J #. In most cases, when compiling the Java applet as a managed library, there is no need to make any changes to the Java small program source code, because the J # Browser Control Runtuance provides support for many of the capabilities in Microsoft Java virtual machines. This includes support for the functionality of the JDK 1.1.4 package and the Java.applet package.
There is no difference between the managed library containing the J # browser controls and the .NET framework. When the user accesses the Web site carries the J # browser control, the J # Browser Control Run library will download the hosting library and run it in Internet Explorer.
Create a J # browser control using the applet class file
If there is only the Java language nature code (.class file) of the Java applet, you can use the Visual J # Binary Converter Tool (JBIMP.exe) to convert the Java applet to a managed library.
Compile the Java applet from the command prompt
You can compile Java applets from the command line using the Visual J # Compiler (VJC.exe). E.g:
C: / appletsources> vjc.exe / target: library /out:myapplet.dll * .java
This command compiles the Java small program source file (with .java extension) into a new .NET framework DLL named myapplet.dll.
You can also use the Visual J # Binary Converter Tool:
C: / appletsources> jbimp.exe / target: library /out:myapplet.dll * .class
If you have installed Visual Studio .NET, you can access the Visual J # Compiler (VJC.exe) and Visual J # Binary Converter Tools from the Visual Studio .NET command window. If you do not install Visual Studio .NET, you must ensure that these tools are located in the path you typed under the command prompt.
When migrating the Java applet using the resource, you must follow the steps described in Upgrading Visual J 6.0 Applications That Use Resources and HOWTO: Resources in Visual J # .NET.
Migrate the Java applet using Visual Studio .NET
If the Java applet is a Visual J 6.0 project, you can also use Visual Studio .NET to migrate it.
Upgrade Visual J 6.0 project using Visual Studio .NET
1. Open the Visual J 6.0 project in Visual Studio .NET. This will start the Visual J # .NET Project Upgrade Wizard. 2. Click Next in all steps of the upgrade wizard. The Upgrade Wizard will convert the Visual J project to a Visual J # .NET class library project. 3. Open the upgrade report to understand whether the wizard detects the problem during the upgrade process. Applet Projects Are Not Supported will be mentioned in the report. You can ignore this error. Before generating a project, you must resolve all other questions listed in the upgrade report. 4. Generate a project. This will compile the Java applet as a managed library. In Visual Studio, you cannot start the J # browser control in Internet Explorer by clicking Debug and then clicking Start or by pressing F5. You must copy the control into the virtual directory of the web server to run it. For more information, see Deploying J # Browser Controls and How To: Debug J # Browser Controls.
For more information on upgrading the Visual J 6.0 project to Visual J # .NET, see Upgrading from Visual J 6.0.
Other steps related to apparatus using the Netscape LiveConnect API
In addition to the migration steps described in the white paper, developers will need to reference an additional assembly when compiling using the Netscape LiveConnect API. The J # Browser Control 1.1B provides support for the LiveConnect API function.
Note If the developer migrates the applet using the Netscape JScript API, you need to install the J # browser control 1.1B on its development, and then you can include references to the assembly.
To compile from the command line, please include this reference as follows:
VJC / R: ??% ProgramFiles% / Microsoft Jsharp Browser Controls v1.1 / vjsjbc.dll ??
/ t: l myappplet.java
If you are using Visual Studio .NET 2003, you need to add a reference to the assembly in the reference list. For more information, see Add Reference Dialog Box.
If you are using JBIMP, use the following command to convert the Java applet to the J # browser control assembly.
JBIMP / R: ??% ProgramFiles% / Microsoft Jsharp Browser Controls
V1.1 / vjsjbc.dll ?? / t: l myapplet.class
Back to top
Update the HTML page to use the J # Browser control
After compiling the Java applet as a J # browser control, the next step is to update the HTML page to start using the control after the migration. The
This white paper contains an example tool called "HTML Approval to Object Tag Converter", which automatically upgrade the HTML page to use the J # browser control. The link used to download the sample tool is located at the beginning of this white paper. Download and run TagConvertSetup.exe to install the HTML applet to Object Tag Converter (TagConvert.exe).
This tool can be used as follows:
TagConvert [options]
E.g:
TagConvert.exe myappletpage.html This tool can be any text file, its extension can be .html, .htm, .asp, and .aspx.
This tool can replace the
ClassID = "CLSID: A399591C-0FD0-41F8-9D25-BD76F632415F" Width = Pixels HEIGHT = Pixels ID = BrowserControlName Align = alignment Hspace = Pixels VSpace = Pixels Vjscodebase = codebaseurl > . AlternateHTML Object> among them: ClassID Download and execute the ClassID of the ActiveX control of the J # browser control. This exact ClassID must be used in the J # Browser Controls VjscoDebase J # Browser Control Class URL and a managed library that contains this class. Symbol "#" is used to separate the managed library file name with the J # browser control class name. If the file name contains a space character, you need to put the VJSCodeBase property value in the quotation marks. The file name must also include a file extension. E.g: Vjscodebase = http://www.microsoft.com/myapplet/myappletclass.dll#myappletclass The basic code can also be a relative URL. For example: if the page is at http://www.microsoft.com/myapplet/myappletpage.htm, Vjscodebase = MyAppletClass.dll # myapppletclass Quote Browser Control MyAppletClass in MyAppletClass.dll in http://www.microsoft.com/myapplet/. If you choose to manually update the HTML page, you can complete the operation by replacing the Conversion process When converting the HTML page, the tool deletes the original The tool creates a backup of the original file before the conversion mark. The backup copy of the file will have a .vjsbak extension. For example, Index.htm will be backed up to INDEX.HTM.VJSBAK. Backup files are created in the directory of the original file. This tool uses the value of the Code = "myappletclass" codebase = http://www.microsoft.com/myapplet Modified to: Vjscodebase = http://www.microsoft.com/myapplet/myappletclass.dll#myappletclass By default, the tool assumes the name of the J # browser control class (for example, myAppletClass) with the name of DLL (MyAppletClass.dll). If the J # browser control class is different from the name of the DLL, you must modify the vjscodebase property value accordingly. Therefore, when using this tool, it is recommended that you compile the Java applet to a managed library with the small program class. E.g: C: / myappletclasssources> VJC / Target: library /out:myappletclass.dll * .java The J # Browser Control Runture is only supported in the vjscodebase property only supports HTTP, FILE, and HTTPS protocols. After specifying the relative path, the Protocol used when loading the HTML page is used to load the J # browser control. The J # Browser control does not support the load control from DOCBASE. The value in vjscodebase must be the same as DOCBASE, or must be one of the subdirectory of DOCBASE. The location referenced by DOCBASE is to load the location of the HTML page. In the conversion process, many properties of Object remain unchanged. Details of the properties converted by TagConvert are described in the following sections. The j # browser control Command line option Supported command line options include: / Recurse: According to the wildcard specification, search for files to be converted in the current directory and all subdirectories. E.g: Tagconvert / recurse * .htm * .html Upgrade all files with .htm and .html extensions in its subdirectory. / Verbose Print the name of the file that has changed during the conversion process. The file name includes a fully qualified path for the file. This tool also prints the total number of files analyzed and the total number of converted files. E.g: Tagconvert / verbose /Appletsources/pages/*.htm> ChangedFiles.txt Upgrade all files with a .htm extension in the specified directory, and dump the name of the modified file to the ChangeDFiles.txt file. / NOLOGO Cancel the copyright information. E.g: Tagconvert / NOLOGO /APPLETSOURES/Pages/*.htm Upgrade all files with a .htm extension in the specified directory and cancel the copyright information. The following table shows the mapping between the properties in the • Archive, Cabbase, and Cabinets properties. In the current version, you don't support packaging a J # browser control into .cab, .zip, or .jar file. The J # browser control must be deployed to the web server as a stand-alone .dll file. • UseSlibrary, UseslibraryCodeBase, UseslibraryVersion, and NameSpace properties. The J # Browser Control Runner does not support the MSJVM's Java Package Manager semantics. If Back to top Deploy J # Browser Control Deploying J # Browser Controls is as simple as simply copying the managers and updated HTML pages to the corresponding directory on the web server or user computers. The web server is no longer a necessary condition for deploying the J # browser control. The managed library must be copied in the directory where the HTML page is located or in a subdirectory. When using the IIS Web server, you must set the ExecutePerMissions field on the virtual directory to Scripts Only, which is the default permission level of the virtual directory in IIS. Deploy multiple DLL browser controls You can split a J # browser control into multiple DLL files. In this case, the DLL containing the main J # browser control class must be referenced in the HTML page. The J # Browser Control Renault will download other DLLs as needed at runtime. When deploying multiple DLL controls, all files related to the same J # browser control must be copied to the same directory. These files must be copied as a standalone file and cannot be packaged into .cab, .zip, or .jar files. Pack multiple J # browser controls into the same library You can also pack multiple J # browser controls into the same manager library. In this case, each J # browser control Vjscodebase = "http://www.microsoft.com/appletdir/myapplets.dll#myapplet1" Vjscodebase = "http://www.microsoft.com/appletdir/myapplets.dll#myapplet2" Because the J # browser control can only be downloaded from the directory where the HTML page is located or in its subdirectory, you may need to copy the managers to multiple locations if the directory of the HTML page is different. Back to top Run the J # browser control on the user's computer In addition to installing a J # browser control running library on your own computer, you don't need to know the J # browser controls. Install J # Browser Control Runtry Support on User Computer Users must use the J # browser control in Internet Explorer after installing the J # Browser Control Runture on their own computer. You and your website administrators need to provide end users to download and install the J # browser controls. The J # Browser Control Runture is also supported using SMS or group policies. For more information on using SMS or group policies to deploy J # browser controls, see http://www.microsoft.com/smserver/techinfo.Aasp or http://www.microsoft.com/windows2000 /TCHINFO/Reskit/dpg/default.asp. J # Browser control security behavior By default, the J # Browser Control Run before running the controls that are running on the Internet web page, will prompt end users. When the user browses the Internet Web site containing the J # browser control, the following dialog is displayed: If the user clicks Yes, download and run the J # browser control. Clicking NO will prohibit the J # browser control to run. If you select Added to Run J # Browser Controls and Don't ask me again checkbox and click Yes, add the web site to the list of website allowed to run the J # browser control. The user will not be prompted when the user has access to a web page on the web site. The default value of the check box is set to be selected. The J # Browser Control Runture is run when running from the Web site on the intranet, does not prompt users. Users can also use the "J # Browser Controls Security Options" dialog provided under "Administrative Tools" in "Control Panel" to manage the list of websites that allow the J # browser control. In Windows XP, you can access the dialog from Performance and Maintenance from "Control Panel". In Windows 98 and Windows Millennium Edition, you can access the dialog from the "Administrative Tools" menu in the "Start" menu. Double-click the J # Browser Control Security icon to open the following dialog: Options include: Disable J # Browser Controls It is forbidden from any web site to run on your computer. Only from Web Sites in this List Only J # browser controls from the web site from the list are allowed. ONLY on the intranet and from web site in this list Only J # browser controls from intranet or from the list of Web sites are run on the computer. This is the default setting. ON Any Web Site Allow J # browser controls from any Web site running on your computer. It is recommended not to use this option, if the use should be very careful. Enter the address of a Web site in the Add Web Site text box, and then click Add, add the web site to the list of website allowed to run the J # browser control. Similarly, select a Web site from the web site allowed to run j # Browser Controls list, and then click Remove to delete the site from the list. Add a Web site to the list of website allowed to run the J # browser control, the user will not be prompted before running the J # browser control on the Web site. By default, the Prompt To Add New Web Sites To this List in the Future check box is selected, which makes the J # Browser Control Runtuct to prompt users before running the J # browser control from the Web site outside the list. When the check box is cleared, the J # browser control from the web site outside the list will not be run, and the user will not be prompted. Back to top Not supported in the current version In the current version of the J # browser control, the following features are not supported: • Trust-based security does not support MSJVM-based security semantics. After migrating the Java applet to the J # browser control, these applets will use the security semantics described in Security Semantics for J # Browser Controls. • Java package manager features supported by Java Pack Manager MSJVM are not supported in J # browser controls. The J # Browser Control does not support object cache (object cache can be used to install the class locally, then use the right restrictions to run these classes through a set of restricted permissions). Therefore, it does not support the installation and running the Distribution Units. • Archive file archive files are not supported. A J # browser control can be split into multiple hosting libraries. However, when deploying multiple library controls to a web server, these files must be copied as a standalone file and cannot be packaged into .cab, .zip, or .jar files. • Java console supports J # Browser Control 1.1B version does not support Java console in Internet Explorer. However, in order to use the console to print statements from the code to debug the J # browser control, the output of Internet Explorer can be redirected to a file. % Program Files% / Internet Explorer / IExplore.exe [HTML Address]> [Output File Path] 2> [Error File Path] • Support for all event syntax does not support any event syntax, only support the following syntax.