PRB: JVC: J0029 and J5020 Errors When Using Language ExtensionsID: Q198322
|
One or more of the following warnings/errors may occur when compiling a Java program that uses Microsoft language extensions:
warning J5020: Directive '@security' ignored--extensions are turned off
-or-
warning J5020: Directive '@com' ignored--extensions are turned off
-or-
warning J5020: Directive '@dll' ignored--extensions are turned off
-or-
error J0029: Invalid character
Microsoft SDK for Java 2.02 (Microsoft virtual machine build 2435) includes the Microsoft compiler for Java (Jvc.exe) version 1.02.7318 or later, which disables Microsoft language extensions by default. Previous versions of the Microsoft compiler for Java (Jvc.exe) did not disable Microsoft language extensions by default.
To compile code that uses Microsoft extensions, you should use the /x-
switch to enable extensions.
Jvc.exe supports the following command-line options for enabling and
disabling language extensions:
/x Disable language extensions (now the default setting)
/x- Enable language extensions
/**
@dll.import("USER32.DLL")
*/
public class Test {
public static void main(String args[])
{
#if MSGBOX
MessageBox(0,"HELLO","Hello World",0);
#else
System.out.println("Hello World");
#endif
}
#if MSGBOX
public native static int MessageBox (int hWnd, String lpText,
String lpCaption, int uType);
#endif
}
jvc Test.java
This produces the following error messages:
Test.java(4,1) : warning J5020: Directive '@dll' ignored -- extensions are turned off
-or-
Test.java(7,1) : error J0029: Invalid character
-or-
Test.java(7,5) : error J0013: Expected '('
-or-
Test.java(8,4) : error J0014: Expected ')'
-or-
Test.java(9,1) : error J0029: Invalid character
jvc /x- Test.java
This produces the following warning message:
If you want to compile the file and define the MSGBOX symbol, you would use the following command:NOTE: Use of the Microsoft language extensions for Java results in compiled code that will run only on Windows systems with the Microsoft virtual machine installed and may not run on other virtual machines. The Microsoft virtual machine is installed with Windows 98, and a freely redistributable version is included with this product. While future versions of Microsoft's Java development tools may be prohibited by court order from incorporating keyword extensions and compiler directives not contained in Sun's Java language specification, any code written and compiled with this version of the product will be unaffected by such a ruling. (Use /nomessage to disable this message.)
jvc /x- /D MSGBOX Test.java
When compiling Java code that contains Microsoft language extensions, it is
possible to disable the warning message by passing the /nomessage switch to
JVC. Older compilers do not support the /nomessage switch and will generate
a "warning J5003: Ignoring unknown compiler option '/nomessage'." To use
the /nomessage switch, your command-line options would be as follows:
jvc /x- /nomessage /D MSGBOX Test.java
If you upgrade Microsoft Visual J++ to use the compiler from the SDK for
Java, it is possible that your Microsoft Visual J++ product will always
disable Microsoft extensions, regardless of the check box "Disable
Microsoft Language Extensions" being selected or not. In this case, to
compile code using language extensions, you will need to add the "/x-"
switch (without the quotes) to the Additional compiler options, in the
Project Properties/Compile tab.
Caught exception: java.lang.UnsatisfiedLinkError: Simple.MessageBox Possible causes: If you are trying to use J/Direct (@dll.import), check your compiler version (for JVC, requires 4336 or greater.) If you are trying to use RNI, there are new requirements: see documentation. Probably wrong version of Java compiler.
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java,
please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Derek
Jamison, Microsoft Corporation
Additional query words:
Keywords : kbGrpJava kbSDKJava202 kbCmpiler kbSDKJava320
Version : WINDOWS:2.02
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: July 28, 1999