Microsoft SDK for Java

Q169799 PRB: Error J0051: Undefined package 'lang'

The information in this article applies to:

Important    This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the Restoring the Registry Help topic in Regedit.exe or the Restoring a Registry Key Help topic in Regedt32.exe.

SYMPTOMS

The following compiler error appears when you try to build simple Java applets or applications:

error J0051: Undefined package 'lang'

This article discusses the possible reasons why this error occurs.

Note   This is not specific to the 'lang' package, but could occur for any package whether implicitly or explicitly imported.

CAUSE

This problem often occurs after installing a virtual machine that supports the Java Package Manager (JPM). Beginning with Microsoft VM build 2252 (installed with Internet Explorer 4.0x or the SDK for Java 2.0x) and later, the JPM contains all the system classes. These VM builds no longer require a Classes.zip file on the CLASSPATH at run-time.

Compilers that do not search the JPM will need to find the system classes on the conventional CLASSPATH (%Windir%\java\classes). To create a single zip file that contains all the system classes, see the RESOLUTION section of this article.

RESOLUTION

The MORE INFORMATION section contains a checklist that provides some of the common fixes for this error.

MORE INFORMATION

  1. Following is a checklist that provides some of the common fixes for this error:

    If you have installed Internet Explorer 4.0x or later or the SDK for Java 2.0-3.1, classes.zip may not have been created on the installation machine. This is caused by a new feature of the Java VM called the Java Package Manager (JPM). The JPM contains the system classes in this release of the Microsoft VM. In order to extract the classes from the JPM for use by tools (such as the Java compiler) that search the class path only, type the following in a command window:

    type clspack -auto

    This creates a new Classes.zip file in the %Windir%\java\classes directory and automatically adds it to the CLASSPATH of the VM. For more information on the clspack utility, please refer to the SDK for Java documentation available at http://www.microsoft.com/java This link takes you to a site on microsoft.com.

  2. Add an existing Classes.zip to your CLASSPATH.

    Warning   Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

    For information about how to edit the registry, view the Changing Keys And Values Help topic in Registry Editor (Regedit.exe) or the Add and Delete Information in the Registry and Edit Registry Data Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Microsoft® Windows NT®, you should also update your Emergency Repair Disk (ERD).

    1. Load the registry editor (REGEDT32.EXE).

    2. Open the HKEY_LOCAL_MACHINE window.

    3. In the View dialog box, make sure the Tree and Data check box is selected.

    4. Expand the SOFTWARE node.

    5. Expand the Microsoft node.

    6. Select the Microsoft VM node.

    The CLASSPATH should read something like the following:

    C:\windows\java\classes\classes.zip;C:\windows\java\classes;

    You can also load Microsoft® Developer Studio® and on the Tools menu, click Options to open the Options dialog box. Click the Directories tab. Make sure the platform is the Microsoft VM. Show directories for class files. Add the directory for your Classes.zip file.

  3. Download the latest build of the Microsoft VM from http://www.microsoft.com/java This link takes you to a site on microsoft.com, click Downloads, and follow the Developer Updates link. The REFERENCE section below lists two Knowledge Base articles that discuss the availability of the current Microsoft VM and how to automatically update the Microsoft VM. You need to run clspack after the new Microsoft VM is installed. See item #1 above.

REFERENCES

For additional information, please see the following articles in the Microsoft Knowledge Base:

Q163638 HOWTO: Automatically Update the Microsoft VM

Q163637 INFO: Availability of the current build of Microsoft VM.

For the latest Knowledge Base articles and other support information on VisualJ++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:

http://msdn.microsoft.com/support/scripting This link takes you to a site on microsoft.com

http://support.microsoft.com/support/java This link takes you to a site on microsoft.com

© 1999 Microsoft Corporation. All rights reserved. Terms of use.