Microsoft SDK for Java FAQ
FAQ
Index
Index

General Questions

Documentation Roadmap , General Questions , ActiveX/OLE Questions , Java Application and Applet Development Questions

Documentation Road Map Questions

General Questions

Microsoft ActiveX/OLE Questions

Java Application and Applet Development Questions


Documentation Roadmap

Where should I begin reading in the SDK for Java documentation?

Be sure to read the Release Notes first. If you are developing Java applets and applications for end users, you might be interested in reading about the tools and classes contained in this SDK for Java. It includes topics such as Packages and Classes, Tools, Java and COM, and Raw Native Interface.

If you are a tools developer, read the information in the Working with Microsoft VM section, available from the left Contents frame.


General Questions

What are the differences between the Microsoft SDK for Java and Microsoft® Visual J++™?

Visual J++ is a Java language product that provides a complete Microsoft® Windows®-based development environment for Java. The Microsoft SDK for Java, on the other hand, is a tool-independent product. It gives developers and tools vendors the latest Microsoft Win32 Reference Implementation virtual machine (Microsoft VM for Java) and Microsoft class library extensions for redistribution, as well as detailed information related to the Java VM, Just-In-Time (JIT) compiler, and other platform components.

How does the SDK for Java relate to the JDK?

The SDK for Java is superset of the JDK, meaning it is fully compatible with the JDK and provides functionality above and beyond what is offered by the JDK.

Version 1.5 of the SDK for Java is compatible with version 1.02 of the JDK. The SDK for Java 2.0, preview release, is compatible with version 1.1 of the JDK.

What operating systems does the Microsoft SDK for Java support?

The SDK for Java runs on Microsoft Windows® 95 or higher and Windows NT version 4.0 or higher. The Java applicatons created with the SDK will run on any platform.

Does SDK for Java 1.5 contain the Application Foundation Classes?

Version 1.5 does not contain AFC classes. The SDK for Java 2.0, preview release, does contain these classes.

What parts of the SDK for Java can I redistribute?

Only the SDK for Java 1.5 has redistributable components; the preview release of SDK for Java 2.0 does not have redistributable components. Read the online release notes of the SDK for Java 1.5. These notes link to the redistribution document that lists all the components that you can redistribute with your application. For terms and conditions of the redistribution, refer to the SDK license. Both license and redistribution documentation (redist.htm) are also part of the SDK download.

What is the current released version number for the Microsoft VM for Java? <b>The most current released version is 1517. This is the version that can be downloaded from http://www.microsoft.com/java.

Build number 1515 is the release of the Microsoft VM for Java shipped with SDK for Java 1.5. Build number 2057 is the version of the VM shipped with the SDK for Java 2.0, preview release. For more information, see the article in the Microsoft KnowledgeBase titled "Availability of Current Build of Microsoft VM for Java" or visit http://www.microsoft.com/java.

When I use JavaTLB to generate classes from some COM object libraries, I get an error J5008. Should I be concerned?

All methods that produce a J5008 warning are omitted from the class file. Often, the cause of this warning is that the method uses a type that is not supported in Java. Note that JavaTLB has been replaced by JavaCOM in the SDK for Java 2.0, preview version.

Can I build an OLE automation server using just the SDK for Java or do I need to buy Visual J++?

The javareg.exe tool was not included with the SDK 1.0, but is part of the SDK for Java, version 1.5.

Is there a way for you to make Java Applets use a .cla file instead of a class file to conform to the 8.3 naming convention (for example, CODE="anim.cla" instead of CODE="anim.class")?

Using the Microsoft Java VM for Win16, you will be able to use long file names by referencing them directly on your Web server in the <applet> tag of the HTML, or by placing them in a uncompressed zip file. The appropriate tag to use a zip file is <Applet code=myclassname CODEBASE=classinzipfile.zip> This would only be necessary for classes that exist on the Win16 local machine.

Where can I obtain the code signing kit? It is not included with the SDK for Java.

You can get the code signing kit in the ActiveX SDK. For more information and to download, click on the Overview link under Authenticode section in the left pane of this page: http://www.microsoft.com/intdev/security/

What version of Microsoft® Internet Explorer (Internet Explorer) do I need to use the Microsoft SDK for Java?

The SDK for Java is a development environment that allows developers to write stand-alone Java programs. Consequently, Microsoft suggests that you download the Internet Explorer version 3.02 browser (or latest version of another browser that supports the Microsoft VM for Java) for testing purposes. If you find any issues related to the Microsoft VM supporting other browsers, please use the Java Bug Report form.

Is there any sample code in the SDK for Java showing how to use the SDK features?

The SDK for Java includes many samples covering the raw native interface, Java/COM integration, calling DirectX libraries from Java, as well as others.

How can I submit feedback about the SDK for Java?

Subscribe to the newsgroup microsoft.public.internetexplorer.java to provide feedback and read feedback from others. To help Microsoft track the bugs, use the online bug report provided on the SDK for Java Web site. Your feedback is appreciated and your suggestions will be carefully considered.

What DirectX technologies are available on Windows NT 4.0?

Windows NT 4.0 provides support for Microsoft® DirectDraw®, DirectPlay®, and DirectSound®. A beta version of the Microsoft Driect3D™ run-time components is provided in the Microsoft® Win32® SDK (from Microsoft Developer Network) for Windows NT 4.0.

Does Microsoft provide native code support?

Yes, the Raw Native Interface provides access to native code support using the Microsoft VM for Java. See the Raw Native Interface documentation for more information.

I installed the Microsoft SDK for Java and discovered I needed Msvcrt.dll to run the Microsoft Java compiler. Where can get this?

The current version of the SDK automatically installs Msvcrt.dll into your \Windows\System directory when you run the setup. If you are missing this dynamic-link library program, download the current Microsoft SDK for Java.

How do I specify a destination directory for the SDK for Java download?

The current version of the SDK for Java has a feature for specifying the destination directory for the download. For installation requirements and instructions, read the online Release Notes in the SDK for Java.

How do I protect my Java object when it is used in native code?

Use the GCFrame, GCFramePop, and GCFramePush classes to inform the garbage collection in the Microsoft VM for Java of your native pointers. Object pointers kept in a garbage collection frame will be automatically updated if the object is moved. For more information about protecting your Java objects when they are used in native code, see "Garbage Collection Issues" in the Raw Native Interface documentation.

Is the SDK for Java available on CD-ROM?

There are CD-ROM versions being released for special events, such as the Site Builder's Conference and the Product Developer's Conference. However, the primary delivery mechanism for the most current binaries and documentation is through the www.microsoft.com site.

How do I get my applet to access the user's local computer?

Any classes used by an applet that access the user's local computer must be installed in the class path of that computer. Use the Cabinet Developer Kit, supplied with this SDK, to bundle classes that access the client computer into a digitally-signed .cab file, which can be downloaded to the client computer and installed on the user's class path.

Will the Microsoft VM for Java support JDBC?

SDK for Java, 1.5 does not support JDBC, but the 2.0 preview version does include this support.

How do I uninstall the SDK for Java?

To uninstall the Microsoft SDK for Java, delete the directory on your hard drive that you installed it in. If you installed the Microsoft VM for Java, it does not need to be removed: It will continue to be used by your existing installation of Internet Explorer 3.02. For SDK for Java 1.5, the Redist.htm file included with the SDK for Java has a complete list of the files in the Microsoft VM if you want to remove them from your hard drive.

How does Msdev.exe relax the security in Internet Explorer so that my applet can run outside the so-called Java sandbox, despite the fact that it is not in a signed .cab file?

In the Microsoft VM for Java that is included with Internet Explorer 3.x, only trusted class files can access resources outside the Java "sandbox." Class files from digitally-signed .cab files are trusted.

If the HTML file is run from Microsoft Developer Studio (MSDEV), the class files are also trusted. This can be very helpful during applet development. However, to deliver your applet to other users, you must put it in a signed CAB file.

When executing or debugging a Java Applet from MSDEV, the security restrictions in Internet Explorer are relaxed for quick and easy testing. MSDEV prepends the project path to the CLASSPATH environment variable that is used by Internet Explorer. This gives the classes trusted status.

What are the redistribution rights with the new version of the Microsoft Win32 VM for Java for the Power PC and Alpha?

The redistributable, self-extracting executable containing the Power PC and Alpha versions of the Microsoft Win32 VM for Java are available by request only. To do so, send a request to sdkjava@microsoft.com. Be sure to put "REDIST" on the subject line of the message.


ActiveX/OLE Questions

What are some good Web sites for learning about COM?

For detailed information and samples covering the COM (Component Object Model) foundations of ActiveX™ technology, see the COM Tutorial at the Site Builder Workshop site.

Can you recommend any reference books for Windows programming or OLE?

Several books from Microsoft Press, including "Advanced Windows" by Jeffrey Richter and "Inside OLE" by Kraig Brockschmidt, make great references for Java developers who want to work with ActiveX technology.

What is a GUID?

A GUID is a globally unique identifier, a 128-bit (16-byte) integer that an algorithm creates. The algorithm uses several factors, including the current date, time, and a computer identifier, to ensure that it will be unique. GUIDs are used extensively in the OLE Component Object Model (COM) and have an important role in Microsoft® ActiveMovie™.

How do I get a GUID?

A GUID can be generated using guidgen.exe. Guidgen, a Windows-native program, is included with Microsoft's Visual C++ products. Developers can also use uuidgen.exe, a console application, from the Win32 SDK.

When do I need to call QueryInterface?

Call QueryInterface whenever you need to obtain an interface for an object.


Java Application and Applet Development Questions

Is it possible for an applet to read a file from my web server? If so, how?

The class below shows how to read a text file named poem.txt from the server. Note: place the .htm and .class files in the same directory on the web server along with a text file named poem.txt with at least one line of text.


import java.io.*;
import java.net.*;
import java.applet.*;
import java.awt.*;

class ReadFile extends Applet {
	public void start () {
		try {
			URL u2 = new URL(getCodeBase(),"poem.txt");
			DataInputStream d = new DataInputStream(u2.openStream());
			String s5 = d.readLine();
			add(new Label(s5));
		}
		catch (Exception e) {
			System.out.println("Error: " + e.toString());
		}
	}
}

The ability to alter the value of System.out and other system streams may be removed or changed in the future.

What are common causes of the "Failed to create object" message when trying to instantiate a COM object written in Java?

When I have an applet in a <FORM> it doesn't submit any information to the server. How can I get the applet to submit its information?

The applet doesn't submit any information because the information a user would want to submit is specific to the applet. For example, an applet that shows images may want to submit the currently displayed image number, while an applet that displays a clock may want to submit the GMT time. It is up to the programmer to write the methods to submit the applet. The five steps below show one way you might implement submitting an applet.

  1. Create an applet with a public function that returns the information you want to submit. (For the first example above, you would return the image number.)
    
           public int getCurrentImage() {
              return m_nCurrImage;
           }
    
  2. Create a Web page with an applet inside your form.
  3. Create a hidden field in the <FORM>, where your applet will submit its data.
  4. Write a script function, like processApplet() in the example below, to populate the hidden field by calling public functions of your applet.
  5. Set your submit button's onClick function to call the script function you wrote in step 4.

Here is the finished product:



      <form action="/scripts/info.dll" method=GET name="myForm" >
      <applet code=AppletInForm.class id=myapplet
       width=320 height=240 >
      </applet>
      <input type=hidden name="appletImage">
      <script language=JScript>
        function processApplet() {
        parent.myForm.appletImage.value=document.myForm.myapplet.getCurrentImage();
        alert("Sending form: image="+parent.myForm.appletImage.value+" user="+parent.myForm.Username.value);
      }
      </script>
      <br>
      Username:<input type=text name="Username"><br>
      <input type=submit value="Please send me the above picture." 
       language="JScript" onClick="processApplet();">
    </form>

How can I get showDocument() to display a URL, when the URL protocol isn't supported by Java (for example FTP)?

The URL class verifies Java protocol support by calling the protocol's Handler class. The four steps below show how to add a protocol and demonstrate how to make the call to showDocument.

  1. Create a package to implement the protocol. For example, .\sun\net\www\protocol\ftp
  2. Implement the Handler class in the sun.net.www.protocol.{protocol-name} package. For example, .\sun\net\www\protocol\ftp\Handler.java.
    
        package sun.net.www.protocol.FTP;
        import java.net.URL;
        import java.net.URLConnection;
        import java.net.URLStreamHandler;
        public class Handler extends URLStreamHandler {
           public synchronized URLConnection openConnection(URL u) {
    	  return new FTPURLConnection(u);
           }
        }
    
  3. Implement any functions your Handler class uses.
    
        package sun.net.www.protocol.FTP;
        import java.io.IOException;
        public class FTPURLConnection extends sun.net.www.URLConnection {
           FTPURLConnection(java.net.URL u) {
              super(u);
           }
           public void connect() throws IOException {
              throw new IOException("FTP doesn't support connect().");
           }
        }
    
    
  4. Create the URL and call the showDocument function.
    
        import java.net.*;
        public class FTPTest extends java.applet.Applet {
           public void init() {
              add(new java.awt.Button("Click to open FTP session."));
           }
           public boolean action(java.awt.Event  evt, Object  what)	{
              try {
                 URL u=new URL("ftp://ftp.microsoft.com");
                 getAppletContext().showDocument(u,"FTPFrame");
              } catch (Exception e) {
                 showStatus(e.toString());
                 e.printStackTrace();
              }
    	  return true;
           }
        }
    

What steps must be followed to use a Java class from an Active Server Page?

First, you must install build 1257 or later of the Microsoft Java VM or else install the SDK for Java 1.5, which includes the latest VM. Then follow these steps:

  1. Create your Java class. For example, here is a class in a file called simple.java:
    
    
    class Simple
    {
            int SimpleFn ( int x )
            {
                    return x * 2;
            }
    }
    
    
  2. From the command line or from MSDEV, compile the .java file into a .class file such as:
    jvc simple.java
  3. Copy the resulting .class file into your java\trustlib directory, such as:
    copy simple.class \winnt\java\trustlib
  4. Register your Java class as a COM object using JavaReg, such as:
    javareg /register /class:simple /progid:Simple

    The /class: argument is the name of the .class file in your trustlib directory. The /progid: is the name that you will use to create your COM object.

    Now your Java class is registered as a COM object and ready to use from ASP.

  5. Create a .asp file in a HTTP shared directory on your machine. Be sure that the directory the file is in has EXECUTE access. You can check this in the "Microsoft Internet Service Manager." A simple ASP file would look like:
    
    <html>
    <body>
    <h1>Simple Test</h1>
    
    The result from SIMPLE is:
    <% Set SimpleObj = Server.CreateObject("Simple") %>
    <% = SimpleObj.SimpleFn(5) %>
    
    <hr>
    </body></html>
    
    

That's it! Open your web browser and point it at YOUR_MACHINE/simple.asp.

How do I redirect output from jview or wjview?

Unfortunately, there is not an option or registry setting for jview or wjview that enables Java logging. However, you can redirect the output when invoking an application like the following example:

jview main > javalog.txt

This works for both jview and wjview. Or, you could programmatically direct the output to a file or pipe by reassigning System.out. The following code, which works for jview/wjview and Internet Explorer, shows how this can be done:


	if ("true".equalsIgnoreCase(System.getProperty("com.ms.applet.enable.logging"))) {
              try {
                String logdir = System.getProperty("java.home");
                PrintStream ps = new PrintStream(new BufferedOutputStream(new
                    FileOutputStream(new File(logdir, "javalog.txt"))), true);
                System.out = ps;
                System.err = ps;
              } catch (Exception e) {
              }
	}

When I create an ActiveX control in Java and then call its methods I get a java.lang.UnsatisfiedLinkError exception. Why can't I call the methods?

The problem is that Applets aren't ActiveX containers and therefore cannot host ActiveX controls. The call to "new myActiveXControl();" doesn't make sense because there is no container to host the control. You should use an <OBJECT> tag in your HTML file, and then pass this object reference to your Applet. For an example of how this is done, see the "OLEControls" sample in the Microsoft Visual J++ samples documentation.

Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.