1

I have a C# code snippet where I read a very old MS Access Database. It is a MS-Access 95 Database, which is not supported in Java's UCanAccess lib. So I had to switch to C# and retrieve the data from here. The process done in C# should be called after specific actions happen, which are done in Java. So I want to call the C# method from Java, if there is a possibility. The database gets updated every now and then because it is connected to an equipment which writes its data to this access database.

Is there a way to call the C' method from Java? Or do you have any other ideas on how to do it?

11
  • 3
    This seems like an X-Y problem, because from your description what you really want is a way to read MS Access 95 files from Java. Commented Sep 24, 2020 at 7:21
  • @VimalCK I believe that it's surely could be solved by building a dll. But this is a way harder to implement than a simple console app. Commented Sep 24, 2020 at 8:05
  • @AndrewPrigorshnev creating and consuming a dll is the simplest solution. Otherwise he should be ready to upgrade his access database to support the java library he use. And if still he cannot do that then write a program in any language to fetch data from access and create an xml or json file in a specific location. His java application should implement a filewatcher mechanism and process the file. Commented Sep 24, 2020 at 8:11
  • @VimalCK Why don't consume data directly from a console application output instead of saving it to file and watching this file on the other side? Commented Sep 24, 2020 at 8:21
  • 1
    @VimalCK You can consume an output of (any) console application in Java like this. And here is an example how to do it in C#. Commented Sep 24, 2020 at 9:45

2 Answers 2

1

Build a simple console application with C# and .NET Framework. This application should just go to the database and return data. Then call this console application from your Java application.

Additionally, consider creating a simple REST service with C# and .NET Framework and consuming it from your Java service. It can be an option if you already have some kind of microservice architecture. Otherwise, it can be overkill.

Sign up to request clarification or add additional context in comments.

Comments

0

Third alternative is to build a DLL from C# code and use it in your java code.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.