Just a note if you ever want to compile that much modules into a single dynamically linked library:
Compile each one with cobc -c (resulting in an assembled, but not linked file, in most cases prog.o) and link the final combined one with cobc -b *.o. This way you have to only recompile changed modules afterwards, not the complete application.
For the actual JAVA-part I'd do what Bill already suggested: have less as possible "external" entry points (you can code a caller which you pass the program to CALL along with the parameters) and leave all the other (existing) COBOL modules as a single file.
Simon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The COBOL programs come out of a program generator. So, the answer is "yes and no". I'll check out the linking options for the shared object, thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2018-08-27
Hi All,
I am very new to COBOL and everything and was wondering if you can help me understand if I need any specific pre-requisites or COBOL related software to make Garry's program work on my Local?
I am good with JAVA but couldn't understand if anything else is required to execute .cbl file using above program as I get below exception:
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest': The specified module could not be found.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As you need javac to comple .java to .class (and maybe creating a jar/exe whatever later) you'll need cobc to compile the execute.cbl to an object file or shared object or C library.
I was trying to call cobol from java using JNA, i used the same example demostrated here but i am getting this error
Libcob Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cob': Native library (win32-x86-64/cob.dll) not found in resource path
([file:/C:/Users/XXXXX/eclipse-workspace/first%20project/, file:/C:/Users/XXXXX/eclipse-workspace/first%20project/jna-4.5.1.jar])
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest': Native library (win32-x86-64/cobsubtest.dll) not found in resource path
([file:/C:/Users/XXXXX/eclipse-workspace/first%20project/, file:/C:/Users/XXXXX/eclipse-workspace/first%20project/jna-4.5.1.jar])
then i changed the library "cob" to "libcob-4" because there is no cob.dll nor libcob.dll.
After that i get below error now i don't know what is wrong please help.
"Libcob Exceptionjava.lang.UnsatisfiedLinkError: %1 is not a valid Win32 application."
I guess java --version shows "64-Bit Server VM" correct (the initial call to "cob" searched for a 64bit version of the dll)?
You can only call to JNA for system libraries that share the same architecture and your GnuCOBOL seems 32bit. So either use a 32bit version of java (you can setup multiple java environments in eclipse) or use a 64bit version of GnuCOBOL (and have the modules compiled as 64bit with the same compiler).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Simon, i am now using 32 bit java and it is working as expected.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2021-07-12
Hi,
I am trying to run jnacob class , using the example but I am getting this error:
java -classpath ./jna-4.2.1.jar; jnacob
Libcob Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cob': Native library (win32-x86/cob.dll) not found in resource path ([file:/D:/Cobol/javacobol/jna-4.2.1.jar, file:/D:/Cobol/javacobol/])
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest': Native library (win32-x86/cobsubtest.dll) not found in resource path ([file:/D:/Cobol/javacobol/jna-4.2.1.jar, file:/D:/Cobol/javacobol/])
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2021-07-12
I did some changes, now I have this:
D:\Cobol\javacobol>java -cp jna-5.8.0.jar; jnacob
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest':
The specified module could not be found.
The specified module could not be found.
The specified module could not be found.
Native library (win32-x86/cobsubtest.dll) not found in resource path ([file:/D:/Cobol/javacobol/jna-5.8.0.jar, file:/D:/Cobol/javacobol/])
I am using:
C:\Program Files (x86)\Java\jdk1.8.0_291\bin
I'm not sure which jnacob you exactly use, in any case: for being able to load GnuCOBOL you have to have the setup as you have shown.
As you seem to want to run COBOL modules: test with cobcrun first (for example you likely have to adjustCOB_LIBRARY_PATH to include the place where the COBOL modules reside).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2021-07-15
I found out the problem, on windows you should run:
cobc -o libcobsubtest.dll cobsubtest.cbl
It worked!
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just a note if you ever want to compile that much modules into a single dynamically linked library:
Compile each one with
cobc -c(resulting in an assembled, but not linked file, in most cases prog.o) and link the final combined one withcobc -b *.o. This way you have to only recompile changed modules afterwards, not the complete application.For the actual JAVA-part I'd do what Bill already suggested: have less as possible "external" entry points (you can code a caller which you pass the program to
CALLalong with the parameters) and leave all the other (existing) COBOL modules as a single file.Simon
But, unless you tell me not to, Gary, I'd like to include that listing in the FAQ as Simon pointed out. Looks worthy of sharing.
Cheers,
Brian
Last edit: Brian Tiffin 2016-01-18
Sure Brian, go ahead.
In at, http://open-cobol.sourceforge.net/faq/index.html#can-gnucobol-interface-with-java
If you notice anything you'd like fixed or improved, drop a note.
Thanks, Gary.
Cheers,
Brian
View and moderate all "Help getting started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
Looks okay to me
creating one cobol stub program as an interface to your 3,500 cobol program which will call other modules based on fuction code that can help.
Last edit: Oscar 2016-01-18
The COBOL programs come out of a program generator. So, the answer is "yes and no". I'll check out the linking options for the shared object, thanks.
Hi All,
I am very new to COBOL and everything and was wondering if you can help me understand if I need any specific pre-requisites or COBOL related software to make Garry's program work on my Local?
I am good with JAVA but couldn't understand if anything else is required to execute .cbl file using above program as I get below exception:
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest': The specified module could not be found.
As you need
javacto comple.javato.class(and maybe creating a jar/exe whatever later) you'll needcobcto compile theexecute.cblto an object file or shared object or C library.Actually Gary had shown this as
For a summary of this thread see https://open-cobol.sourceforge.io/faq/index.html#java-native-access
cobcis the GnuCOBOL compiler executable, so yes: you'll need to have GnuCOBOL installed to follow this examples.A summary about ways to do this can be found at https://open-cobol.sourceforge.io/faq/index.html#how-do-i-install-gnucobol - in case you have any issues give the search in the discussion boards a short try and post a new topic if you still have questions.
Last edit: Simon Sobisch 2018-08-27
I was trying to call cobol from java using JNA, i used the same example demostrated here but i am getting this error
Libcob Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cob': Native library (win32-x86-64/cob.dll) not found in resource path
([file:/C:/Users/XXXXX/eclipse-workspace/first%20project/, file:/C:/Users/XXXXX/eclipse-workspace/first%20project/jna-4.5.1.jar])
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest': Native library (win32-x86-64/cobsubtest.dll) not found in resource path
([file:/C:/Users/XXXXX/eclipse-workspace/first%20project/, file:/C:/Users/XXXXX/eclipse-workspace/first%20project/jna-4.5.1.jar])
then i changed the library "cob" to "libcob-4" because there is no cob.dll nor libcob.dll.
After that i get below error now i don't know what is wrong please help.
"Libcob Exceptionjava.lang.UnsatisfiedLinkError: %1 is not a valid Win32 application."
Last edit: thomas 2019-09-04
I guess
java --versionshows "64-Bit Server VM" correct (the initial call to "cob" searched for a 64bit version of the dll)?You can only call to JNA for system libraries that share the same architecture and your GnuCOBOL seems 32bit. So either use a 32bit version of java (you can setup multiple java environments in eclipse) or use a 64bit version of GnuCOBOL (and have the modules compiled as 64bit with the same compiler).
Thanks Simon, i am now using 32 bit java and it is working as expected.
Hi,
I am trying to run jnacob class , using the example but I am getting this error:
java -classpath ./jna-4.2.1.jar; jnacob
Libcob Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cob': Native library (win32-x86/cob.dll) not found in resource path ([file:/D:/Cobol/javacobol/jna-4.2.1.jar, file:/D:/Cobol/javacobol/])
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest': Native library (win32-x86/cobsubtest.dll) not found in resource path ([file:/D:/Cobol/javacobol/jna-4.2.1.jar, file:/D:/Cobol/javacobol/])
I did some changes, now I have this:
D:\Cobol\javacobol>java -cp jna-5.8.0.jar; jnacob
subtest Exceptionjava.lang.UnsatisfiedLinkError: Unable to load library 'cobsubtest':
The specified module could not be found.
The specified module could not be found.
The specified module could not be found.
Native library (win32-x86/cobsubtest.dll) not found in resource path ([file:/D:/Cobol/javacobol/jna-5.8.0.jar, file:/D:/Cobol/javacobol/])
I am using:
C:\Program Files (x86)\Java\jdk1.8.0_291\bin
I'm not sure which jnacob you exactly use, in any case: for being able to load GnuCOBOL you have to have the setup as you have shown.
As you seem to want to run COBOL modules: test with
cobcrunfirst (for example you likely have to adjustCOB_LIBRARY_PATHto include the place where the COBOL modules reside).I found out the problem, on windows you should run:
cobc -o libcobsubtest.dll cobsubtest.cbl
It worked!