In Java-to-.NET project, can’t access a proxy in a System.* namespace

In a Java-to-.NET project, you've proxied, and are trying to access a .NET class in a System.* namespace (for example, System.Transactions.CommittedTransaction).Your Java IDE or compiler won't let you reference the class.

 

The problem is that java.lang.System is a standard Java class, and the IDE assumes that any proxy class whose full name begins with System.* is actually a member of java.lang.System.

 

To work around this problem, add the line

 

import System.Transactions.CommittedTransaction;

 

to the start of your Java file. Then, in your code, simply reference CommittedTransaction. It'll now work.

 

You must do this for every proxy class in a System.* namespace; you can't simply import System.* or System.Transactions.*.

 

This will even work when your proxy class's name conflicts with the name of a standard Java class. For example, to access the proxy of the .NET class System.Object, simply add

 

import System.Object;

 

Now, all references to Object in your Java file are to System.Object. (To reference the Java Object class, you'll need to explicitly use the fully qualified name java.lang.Object.)