Microsoft KB Archive/172794

-

{| The information in this article applies to:
 * width="100%"|
 * Microsoft Visual J++, versions 1.0, 1.1

SYMPTOMS
Creating a class whose name is the same as the \package in which it resides generates the following error when compiling a Java program that imports this package:

error J0049: Undefined name 'package' Where "package" is the name of your package.

RESOLUTION
To workaround the problem, import the class name explicitly into your Java program or rename the class to ensure that it has a different name than the package. This problem has also been corrected see the STATUS section below for the current fix.

STATUS
This problem has been fixed with the Microsoft compiler for Java (Jvc.exe) version 1.02.4224 that is included with the Microsoft SDK 2.0 for Java Beta2. The SDK for Java is available at http://www.microsoft.com/java/.

Steps to Reproduce Behavior
 Create a new Java project called LibX and specify the location as C:\LibX. On the ClassView pane, right-mouse click and Create a New Class called "Lib," which Extends Frame, and in the package Edit Box specify "Lib" as the package name and check the Public Access Specifier.  Include the following code to the Lib.java file that was created from Step 2. Note: Replace the "import java.awt.frame" that Visual J++ generates with the following import statements: import java.applet.*; import java.awt.*; // // // Lib // // public class Lib extends Frame { //constructors ... public Lib { } public static void Method1(String msg) { } }  Build the Lib package.  Also include c:\LibX to the CLASSPATH. One way of doing this is to run REGEDIT from the command-line and select: HKEY_LOCAL_MACHINE SOFTWARE Microsoft Java VM Edit the Classpath Key to include c:\LibX.  Using Visual J++ 1.1, create a new default Java Applet Wizard named "MyApplet" in the location c:\LibX.  Include import Lib.*; to the beginning of MyApplet and also include the following code to the init method of MyApplet.java: import Lib.*; ...     public void init { resize(320, 240); Lib.Method1("ssss"); Lib myLib=new Lib; }  When you build MyApplet.java, you will see the above error.</li></ol>