Highlighted
Trusted Contributor.
Trusted Contributor.
483 views

How to compile copies not to default package

Jump to solution

Hi,

we are using VC2.3 and have the problem, that the copies, which are in a Copybook-project are compiled in the default package.
The cobol programs within a Cobol-JVM-Project which are using the copies are compiled in the package which is defined as PROGRAM-ID.
The problem is, that classes of a java project can not use classes of default package, e.g. we can instanciate the programs but not the copies .
Is there a possibility to compile all copies a package mycopies, maybe with an directive ?

Thanks a lot !

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Herbkoeg,

I have a suggestion. JVM COBOL provides an alternate way to specify the namespace (or package name) with a compiler directive. Try removing the "de.herbert" from the Program ID in your program, so that the Program ID is just "Program1". Then, add the directive ilnamespace(de.herbert) to your specified compiler directives in the JVM COBOL project, and rebuild that project. This way, you should end up with both the Program1.class and the Copy1.class created under /bin/de/herbert.

Blair McDonald

View solution in original post

4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

I don't understand the problem that you are reporting.

A copybook project does not get compiled at all. It is used to hold copybook members so that by referencing the copybook project from another project the compiler will resolve the references and bring the required copybook members in during compilation.

What error is it that you are receiving?

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Thanks for your answer!

I have 3 projects:

- MyCopyBook   -> Copy1.cpy

- MyJvmProject (referencec MyCopyBook-Copybooks)  -> Program1.cbl which is using copy1.cpy and has the program-id de.herbert.program1

IDENTIFICATION DIVISION.
*************************
...
PROGRAM-ID. de.herbert.PROGRAM1.
LINKAGE SECTION.
*---------------
COPY COPY1.
*
***********************************
PROCEDURE DIVISION USING COPY1 .
***********************************
...

- MyJavaProject: This project references MyJvmProject, here i want to call program1 with copy1  -> MyJavaCobolDemo.java

In the bin folder of MyJvmProject I can found the classes which are generated:

/bin/de/herbert/Program1.class <- de.herbert package

/bin/Copy1.class <- default package

Now, in MyJavaCobolDemo.java, I try to call Program1:

---------------------------------------------------------

package de.herbert.coboldemo;

import de.herbert.Program1; // <- works fine ...

import copy1 // <- will not work 

public static void main(String[] args) throws Exception {

PROGRAM1 program1 = new PROGRAM1(); // -> no Problem

Copy1 copy1 = new Copy1(); //  <- will not work, because you can not instanciate an object which is in default package

program1.program1(copy1); ..

.---------------------------------------------------------

When i move MyJavaCobolDemo.java to the default package, it works, because in default-package you can create instances from classes which are in default package. But that woud only move the problem to an other position.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Herbkoeg,

I have a suggestion. JVM COBOL provides an alternate way to specify the namespace (or package name) with a compiler directive. Try removing the "de.herbert" from the Program ID in your program, so that the Program ID is just "Program1". Then, add the directive ilnamespace(de.herbert) to your specified compiler directives in the JVM COBOL project, and rebuild that project. This way, you should end up with both the Program1.class and the Copy1.class created under /bin/de/herbert.

Blair McDonald

View solution in original post

Highlighted
Trusted Contributor.
Trusted Contributor.

Thanks a lot 🙂 !

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.