Skip to main content

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Can you please zip up your sample project including the .jar file that you are trying to use and attach it to your reply?

Thanks.

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
The likeliest thing is that you have not put your current directory on the Java classpath. From whichever directory contains Program1.class, try this:

java -cp . Program1

that puts your current directory on the classpath, and then the JVM will find your class files.

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Chris Glazier originally wrote:
Can you please zip up your sample project including the .jar file that you are trying to use and attach it to your reply?

Thanks.


Hello Chris,

I don't know how I can attach the project in a message here. Could you please give me your e-mail address?

Thank you

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Chris Glazier originally wrote:
Can you please zip up your sample project including the .jar file that you are trying to use and attach it to your reply?

Thanks.


Hello Chris,

I don't know how I can attach the project in a message here. Could you please give me your e-mail address?

Thank you

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
You can write me to miguel.ossa@mango.com

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Paul Kelly originally wrote:
The likeliest thing is that you have not put your current directory on the Java classpath. From whichever directory contains Program1.class, try this:

java -cp . Program1

that puts your current directory on the classpath, and then the JVM will find your class files.


Program1.class does not exist because compilation fails! I don't know how to handle this; it is a COBOL program.

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Hello,

I have uploaded the project to Fetch.IO.

Here is the link: Project on Fetch.IO

Regards

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Hello,

I have uploaded the project to Fetch.IO.

Here is the link: Project on Fetch.IO

Regards

[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Hi Miguel

The Java project you've uploaded doesn't compile (lots of hardcoded paths to jars on your machine), but I can see a couple of issues. The first is, you need to put your fproc_JavaSWT project on the build path of your COBOL project. You can do that by bringing up the properties for your COBOL project, selecting Java Build Path and selecting it on the project tab. Including the jar output from the Java project (which you said you did) is an alternative. The next issue is that your class, pantalla, is in the package fproc_JavaSWT.

So its full type name is fproc_JavaSWT.pantalla . So for example:

77 cPantalla type fproc_JavaSWT.pantalla.

set cPantalla to new proc_JavaSWT.pantalla

Alternatively, you can set the ilusing directive to import the namespace into your project. Go to the project properties again, and add ilusing(fproc_JavaSWT) to the additional directives field. If you add the directive, you don't need to qualify every reference to pantalla with its package name.

If you haven't done a lot of Java programming, it might be worth familiarizing yourself with packages and how they work in the JVM world - you could do worse than start here:

download.oracle.com/.../packages.html




[Migrated content. Thread originally posted on 15 July 2011]

Hello,

I want to use a java public class from a COBOL JVM project. The program I use in order to do this is named "Program1.cbl". Here you can see how simple it is:

program-id. Program1 as "Program1".

data division.
working-storage section.
77 cPantalla type pantalla.
77 text1 pic x(10).

procedure division.

display "Hello, I am Program1!".

set cPantalla to new type pantalla.
invoke cPantalla:open().


goback.

end program Program1.

In Properties->Java build path->Libraries I have included the runnable jar generated from the Java project. The jar file is stored at c:\\.

The IDE does not recognize the type "pantalla" presumably populated by the java package. And the following error occurs:

java.lang.NoClassDefFoundError: Program1
Caused by: java.lang.ClassNotFoundException: Program1
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Any ideas? What the heck am I doing wrong? Do you need the sample code?

Regards
Thank you. I was not able to solve the problem using the steps you described. I finally found that there were errors in previous layers of the project that were masked inside the jar. In order to resolve this issue, I used a previous version of the program and then I gradually copied & pasted the new code into the diferent sources. Then, errors related with the scope of several variables appeared. Solved this, the program begun working correctly.

A bit messing. Perhaps these problems have anything to see with Eclipse IDE.

Regards