Ensign
Ensign
1813 views

Calling obj file from Java on UNIX

Jump to solution

I am evaluating Microfocus Enterprise Developer in part to make a Java 1.8 call to a 64 bit COBOL executable on Unix. When I build for Unix, the output is an obj file. The question is how can we call this in Unix from JAVA. I know on windows i can load a DLL using System.load() in Java - what is the equivalent when calling an obj file on Unix?

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

You cannot generate an .so file if you are running under Windows. There is an add-on to the ED Eclipse product for doing remote development under Unix that would be required to actually generate a Unix/Linux executable on the target machine.

For Visual COBOL it is called the Development Hub but for Enterprise Developer it is called Micro Focus Enterprise Developer UNIX Components, I believe.

You will need this add-on if you are developing apps that target Linux/Unix systems.

View solution in original post

0 Likes
3 Replies
Micro Focus Expert
Micro Focus Expert

When you build for Unix/Linux the output will be either an executable file or a shared object with the extension .so (may differ depending on system). These .so files are akin to a .dll under Windows.

In either environment you should be using the COBOL Java run-time library calls to load and run your COBOL applications. This is documented under the section Java and COBOL

From Java you should be loading the COBOL modules using the cobload function:

{  
  if (RuntimeSystem.cobload("mycbl") != 0)
     System.out.println("Could not load library\n") ;
  else
     System.out.println("Library loaded successfully\n") ;
}

And to call the COBOL you should be using one of the cobcall functions:
import com.microfocus.cobol.* ;
class SimpleCall
{
   public static void main(String argv[]) throws Exception
   {
       int i = RuntimeSystem.cobcall_int("legacy", 
		            	new ParameterList()
	                   			.add((int)4
                      	.add((int)7
                   				.add((byte)'a'));
       System.out.println(i) ;
   }
}

Please look at the documentation using the link that I provided above.

Thanks.

0 Likes
Ensign
Ensign

Thank you Chris but Enterprise Developer did NOT generate an .so file - only .obj and idy - when I set the LINK target OS for Uni/Linux.  For Windows I do get a DLL. I do not believe I can generate an .so file from NetExpress either.

0 Likes
Micro Focus Expert
Micro Focus Expert

You cannot generate an .so file if you are running under Windows. There is an add-on to the ED Eclipse product for doing remote development under Unix that would be required to actually generate a Unix/Linux executable on the target machine.

For Visual COBOL it is called the Development Hub but for Enterprise Developer it is called Micro Focus Enterprise Developer UNIX Components, I believe.

You will need this add-on if you are developing apps that target Linux/Unix systems.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.