Calling C # dll from Java

I am a Java developer. But for some reason I have to take on C # help to complete my task. I have the below C # code which is used to create a DLL. This dll should be used in my java program to make it necessary.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace Yrl.Tracingtool
{
public class DocxUtil
{
    public Application Jump(string fileName)
    {

        object fileNameAsObject = (object)fileName;
        Application wordApplication;
        try
        {
            wordApplication = new Application();
            object readnly = false;
            object missing = System.Reflection.Missing.Value;
            wordApplication.Documents.Open(ref fileNameAsObject, ref missing, ref readnly, ref missing,
                                            ref missing, ref missing, ref missing, ref missing,
                                            ref missing, ref missing, ref missing, ref missing,
                                            ref missing, ref missing, ref missing, ref missing);
            object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
            object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToFirst;
            object count = 3;

            wordApplication.Selection.GoTo(ref what, ref which, ref count, ref missing);

            return wordApplication;
        }
        catch (Exception ex)
        {
            //LogEntry log = new LogEntry();
            //log.Categories.Add("Trace");
            //log.Message = ex.ToString();
            //Logger.Write(log, "Trace");
            throw new System.IO.FileLoadException("File cannot be opened");
        }
        finally
        {
            wordApplication = null;
        }
    }
}
}

I also checked this forum and other forums, but most of them talk about using a C ++ or C DLL file in a JNI call. If anyone knows about calling a C # DLL from Java, please let me know.

+5
source share
2 answers

We use ICE to exchange data between .NET and Java applications. This is not exactly what you need, but it can help.

googling ".NET Java bridge" - (jni4net, JNBridge ..)

+2

All Articles