Click here to Skip to main content
15,888,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

Thanks in advance.

I have CP52OO.dll file which is used to communicate with CP5200 controller. DLL is 32 bit and 64 bit dll vrsion is not available. Provider is unable to provide same.

So I imported same dll in c# project ON 64 bit system and completed my controller testing work. Testing utility is working fine.

Now the problem is I need to communicate with controller using java application only. I tried to generate c# dll and tried to import it in java application but I failed to import that dll too.

Now I finally come to conclusion that I have to develop windows service in .net using c# code, and java application will call that service.

I am started working on windows service. Meanwhile I want some better approach from world developers how can I handle this problem.

Please consider below points while providing approach :
1] As 64 bit dll is not available I can not make my java application system dependent.
2] C# code is working perfectly fine. but C# dll importing in java application also facing issue as we can not consider c# as module.
3] Approach should be robust there should not be any dependency on system, execution time should not be long.

What I have tried:

I have tried all possible ways to load library file in java. But dependency can not be removed as dll is 32 bit.
Posted
Updated 25-Sep-16 22:00pm
v3
Comments
Garth J Lancaster 26-Sep-16 3:17am    
ok, some of your requirements are a bit 'hazy' ..

a) are you saying you're running a 64bit JVM and thats why you cant (JNA or JNI) call a 32bit DLL ?
b) what is CP5200.dll/CP5200 Controller ? how much data is transferred in either direction for example, how many functions does the CP5200.dll export ?
c) not sure why you're talking about c# dll import into java - why do you need c# ? you seem to have

java program -> (something) -> CP5200.dll (CP5200 Controller)

and it's the 'something' you're looking for - yet adding too much into 'something' may break your point 3 'robustness' clause / dependencies
[no name] 26-Sep-16 3:30am    
Hello Gath J Lancaster,

Thanks for comment.

Please check below information about your queries

a] Yes I am using 64 bit JVM and I am not able to import 32 bit dll. I know that if I will use 32 bit jvm I may able to import dll file but I do not want to add any dependency in application like 32 bit jvm only.

b] CP5200 Controller used in LED Display hardware. CP5200.dll export multiple functions to connect, disconnect, send text, send picture like wise.

c] As I found that I am unable to import CP5200.dll in java. Then I tried to import in C#, and I am able to do that. I called multiple functions successfully using C# code. So I created new C# dll which is calling functions from CP5200.dll. Then I tried to Import C# dll in java project but I am unable to do that. So I thought that I may create one windows service using currently successfully running C# code. Java application will communicate with that windows service

Yes I am looking for something like
Java Application -> C# Windows Service -> CP5200.dll

I am not confident and sure about above approach. So asking for opinions and better approach.
Garth J Lancaster 26-Sep-16 3:40am    
ok, so, why 'C# Windows Service' .. thats another dependency isnt it

why not

Java Application --- Some form of IPC ---> C++ 'server'/'service -> CP5200.dll

?
[no name] 26-Sep-16 5:12am    
I am not really sure about C# service that's why I am here. I need good approach.

Could you please explain Some form of IPC means ?

1 solution

As I have already explained in your previous two questions on this subject, you need to use the Java Native Interface to use a dynamic link library from Java.
 
Share this answer
 
Comments
[no name] 26-Sep-16 5:02am    
I appreciate your efforts giving same answer again and again. But I am unable to use your approach that I already mentioned.
Richard MacCutchan 26-Sep-16 6:11am    
Then kindly explain exactly what your problem is. Using a DLL from Java via the JNI is perfectly straightforward and does not need any C# interface or Windows service in order to make it work.
[no name] 26-Sep-16 6:15am    
I am able to load dll file on 32 bit machine, but I do not want any dependency like this my application will work on 32 bit JVM only. As 32 bit dll is available from provider. 64 bit dll is not available. So I am unable to run application 64 bit JVM
Richard MacCutchan 26-Sep-16 6:21am    
Then run it in the 32 bit; the dependency is causeed by the DLL and if the supplier will only provide 32 bit then you have no choice. I am also somewhat confused why you want to do this in Java if it already works in C#. you seem to be determined to make life more difficult for yourself than it needs to be.
[no name] 26-Sep-16 7:15am    
As you have read above question, this dll is used to communicate with LED hardware, I have 10 different other hardware, that code is already written in core [JAVA Based] application which is communicating with all hardware.

Now you suggest me how should I communicate with LED hardware from core application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900