Skip to main content

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo
You should be able to add jar files to the COBOL JVM project by right clicking on the project name and selecting Properties.

Highlight Java Build Path and select the tab for Libraries.

You can then click Add Jars... or Add External Jars... in order to make the jar file visible to your project.

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo
Hi Chris,

that is the way it should work, but it doesn't.
When compiling the cobol source, the classpath from the Java Build Path isn't taken in account.

I have tried it with a .jar archive and with a class folder, but i always get
COBCH0845S Unknown class 'com.easypaygroup.javacobol.Content'

Are there samples available of Eclipse projects with Cobol JVM that do this ?

Regards,

Renzo

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo
Hi,

We are looking into a work around for you right now. This is a know issue which is being fixed for the full release; for now I am sure we can get you up and going again.

Best wishes - AJ

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo
I've just tested this out....

set an addition directive on your cobol compilation - JVMCLASSPATH(c:\\content.jar) - replace my exmaple path with your real one and it will work - though the declaration of the showContent method needs to be static to match the way you're calling it in the cobol.

What was previously suggested should have worked, and Alex says we'll be looking to address that in the next release.

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo
Hi Chris,

Eureka, it works !

What do you mean with "though the declaration of the showContent method needs to be static to match the way you're calling it in the cobol" ?

Is there another way in cobol than the "invoke type" command, so that i don't have to use static methods ?

Regards,

Renzo

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo
You can use the New method to create an instance of a class and store it in a data item.
You can then call the instance methods within that object.

01 lsTestInstance   type   TestClass.

   set lsTestInstance to new type TestClass
   invoke lsTestInstance::myMethod()

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo
Thanks,

small step for man, giant leap for (RM/Cobol) mankind.

Regards,

Renzo

[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

.....and Alex says we'll be looking to address that in the next release.....Could you please say to me what new Release will be this ???

PJM


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

This post was from several years ago and this particular problem has been addressed back then and should no longer occur with any current release.

Are you still experiencing a problem in this area?


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

YES, I replicated the example  :

package javacobol;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

public class Javacobol main {

private String content = "Initial value";

public static void main showContent(){

System.out.println(content);

public static void main(String[] args) {

Content content = new Content();

content.showContent();

}

}

And get the same problema.....I am using the versión of Visual Cobol enclosed.

 

TKS

 

 

 

 

 

PJM


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

I am not sure I understand what it is that you are trying to do here...

In the original post, the user was trying to invoke a method in a Java class from a COBOL main program.

What was fixed was that you can now add the .jar file containing the java class to the COBOL project build and it will pick up the class reference correctly.

In your java example, which appears to be invalid, you are defining a main entry point which means that this java program would be the main program and not the COBOL.

Can you show me the COBOL code that you are using and provide detail on what you are attempting to do?

Thanks.


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

Dear Chris,

The only thing that I want is  a Java program calling a Cobol program without to get this error "Error: not found or loaded main class javacobol.java"

I enclosed the Export of "my Project". Remember that I using Visual Cobol 2.1 Update 1

Thanks,


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

You need to create two projects for this, a java project containing the java main program and then a COBOL JVM project that will create the COBOL class.

Please take a look at the section in the documentation on interoperation between Java and JVM COBOL here:
This includes a tutorial that you should run thru and get working prior to trying this with your own application.

Thanks.

 


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

Chris,

I did the two Projects....Colud you please say what is wrong


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

You have the incorrect project reference set in the properties for the Java project.

You have the reference set to CobolJVM but it should be referencing COBOLProject instead.

You also have an error in your Java source code as it appears that you were trying to experiment with the tutorial.

Please change the source back to the original as shown in the docs and try again.

Thanks.


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

Dear Chris,

So sorry but I Did it again step by step and something is wrong yet. could you please say what is WRONG here ??

 

Many Thanks in Advanced

PJM


[Migrated content. Thread originally posted on 17 February 2011]

Hello,

is there a way to add libraries to the classpath in Eclipse.
I have a class in a .jar file (code below) :

package com.easypaygroup.javacobol;

public class Content {

private String content = "Initial value";

public void showContent(){
System.out.println(content);
}
public static void main(String[] args) {
Content content = new Content();
content.showContent();

}

}

And i have a COBOL JVM project with the following source :

program-id. testjava as "testjava".
environment division.
configuration section.
data division.
working-storage section.

procedure division.
invoke type java.lang.System::out::println("help")
invoke type
com.easypaygroup.javacobol.Content::showContent().

goback.

end program testjava.

I do not get it compiled in Eclipse. Adding the jar library to the classpath in Eclipse doesn't help.
Do i need to modify the ant build file ?

Regards,

Renzo

I am not sure what went wrong with your project but it had no bin folder and was not set up correctly.
I ran the tutorial here and I have attached a zip file containing the two project zips.

Please try these and see if you can get it to work.

All you should have to do is adjust the references to the cobol run-time to point to the ones on your computer which is 32-bit I believe.

Thanks.