PRB: JVC: J0029 and J5020 Errors When Using Language Extensions


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
warning J5020: Directive '@com' ignored--extensions are turned off
warning J5020: Directive '@dll' ignored--extensions are turned off
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


Steps to Reproduce Behavior

  1. Create a file named that contains the following:

          /**      @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      }
  2. Compile the file using the following command:

    This produces the following error messages:,1) : warning J5020: Directive '@dll' ignored --
    extensions are turned off
    -or-,1) : error J0029: Invalid character
    -or-,5) : error J0013: Expected '('
    -or-,4) : error J0014: Expected ')'
    -or-,1) : error J0029: Invalid character
The correct way to compile a file that uses Microsoft language extensions
is to use the following command-line:

jvc /x-
This produces the following warning message:

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.)
If you want to compile the file and define the MSGBOX symbol, you would use
the following command:

jvc /x- /D MSGBOX
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
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.

If you compile code and receive the J5020 warning, the .class file
generated may not function properly. You should recompile using the "/x-"
switch. Failure to do so may result in the following error message when
running your application:

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 support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:


Id. de artículo: 198322 - Última revisión: 02/14/2017 - Revisión: 1

Microsoft Software Development Kit for Java 2.02, Microsoft Software Development Kit for Java 3.2