Search code examples
javadlljaribm-mqikvm

How do I use IKVMC to convert a specific JAR file to DLL when the jar file has various outgoing dependencies?


I'm working with Websphere MQ. And I need to convert a specific JAR file to a DLL. Here is the collection of JARS from the WMQ Client. Here is the JAR Analyzer File for the collection listing the various incoming and outgoing dependencies.

The File I want to convert is com.ibm.mq.jar which has the following outgoing dependencies -

 com.ibm.mq.commonservice.jar
 com.ibm.mq.headers.jar
 com.ibm.mq.jmqi.jar

The problem is I don't know what command to pass in the command prompt to convert the jar without losing any of the classes.

Basically, I need to get access to MQMessage and MQMD which are part of com.ibm.mq.jar but when I convert it by itself, those specific classes doesn't get imported.

I took a look at another similar StackOverflow Question but the main difference is that the dependencies are circular.

For example, com.ibm.mq.headers.jar depends on com.ibm.mq.jmqi.jar and vice-versa.


Solution

  • I have no idea why you will not read the MQ link that I gave.

    (1) Create a pure '.NET managed' MQ application

    int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
    Hashtable qMgrProp = new Hashtable();
    qMgrProp.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);  /* very important */
    qMgrProp.Add(MQC.HOST_NAME_PROPERTY, "10.10.10.10");
    qMgrProp.Add(MQC.CHANNEL_PROPERTY, "TEST.CHL");
    qMgrProp.Add(MQC.PORT_PROPERTY, 1414);
    qMgrProp.Add(MQC.USER_ID_PROPERTY, "myUserID");
    
    try
    {
       MQQueueManager _qMgr = new MQQueueManager("MQA1", qMgrProp);
    
       MQQueue queue = _qMgr.AccessQueue("TEST.Q", openOptions, null, null, null);
    
       /* Do whatever you want to do */
    
       queue.Close();
       _qMgr.Disconnect();
    }
    catch (MQException mqex)
    {
       System.Console.Out.WriteLine("MQTest01 cc=" + mqex.CompletionCode + " : rc=" + mqex.ReasonCode);
    }
    

    (2) Compile it.

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe /nologo /t:exe /r:System.dll /r:"C:\Program Files (x86)\IBM\WebSphere MQ\bin\amqmdnet.dll" /out:bin\Release\Test.exe Test.cs  Properties\AssemblyInfo.cs
    

    (3) Create "Test.config" file (to go with Test.exe) where Test.exe is stored

    <configuration>
      <appSettings>
        <add key="NMQ_MQ_LIB" value="managed"/>
      </appSettings>
    </configuration>
    

    (4) Copy 3 files to your target PC: Test.exe, Test.config and amqmdnet.dll and then run it. You may need to update the PATH environment variable to point to the directory that amqmdnet.dll resides in. This is generally not needed but sometimes Windows get picky.