PDA

View Full Version : Trying to call NT7 .NET interface from Java, looks like it worked


Marzullo
04-11-2010, 04:11 AM
I am not an expert of .NET so I decided to exploit my existing java knowledge to use NT. I've seen in the documentation you've removed COM interface (why?), I am not a COM expert too but all I know is .NET can be also seen as COM object from outside.

The only free tool I could find on the net to call a com object from java is com4j (https://com4j.dev.java.net/runtime-semantics.html).

With such tool, I did run a command against your tlb definition (ninjiatrader.client.tlb) and got some usable java proxy to call your client, attaching them to the post.

This is the sourcecode I am using to call your interface from java:


public static void main(String[] args)
{
_Client comObj = ClassFactory.createClient();
IClient ntClient = comObj.queryInterface(IClient.class);

int ret = ntClient.connected(0);
System.out.println(ret);
}
This code is printing 0, as soon as I enable AT from within NT 7.
I wondered if this could be a "safe" way to interop with your interface or would you suggest anything else? I could do everything in C# but I lose years and years of java exp, that'd be silly...

NinjaTrader_Austin
04-11-2010, 01:27 PM
Marzullo, creating an interface to the ATI with Java could certainly work but it is definitely unsupported.