- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: calling C from java
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 11:50 AM
тАО04-02-2009 11:50 AM
calling C from java
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 12:13 PM
тАО04-02-2009 12:13 PM
Re: calling C from java
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 12:16 PM
тАО04-02-2009 12:16 PM
Re: calling C from java
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 01:38 PM
тАО04-02-2009 01:38 PM
Re: calling C from java
Calling C shouldn't be any different from Cobol or Fortran. The VMS calling standard is specifically designed to make intra language calls possible, and relatively painless.
The biggest issue is matching data types between the languages. There should be a better match for data types between Java and C, as you may not need to worry about string descriptors and packed decimal types.
Start with your existing Fortran example, and replace the Fortran routine with a C equivalent. Make sure you can receive and return all the data types you're interested in.
I'd expect far more people to be calling C from Java than Cobol. Chances are, the reason you can't find any example code is it's too easy!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 09:40 PM
тАО04-02-2009 09:40 PM
Re: calling C from java
Please contact me offline and I would
be happy to provide you with few examples
that call C from Java.
Regards,
Guy Peleg
Maklee Engineering
www.maklee.com
guy.peleg@company_name.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 09:51 AM
тАО04-03-2009 09:51 AM
Re: calling C from java
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 11:33 AM
тАО04-03-2009 11:33 AM
Re: calling C from java
:-)
$ type y.c
#include
main() { printf("guy.peleg@%s.com","maklee"); return 1; }
$
$ cc y
$ link y
$ run y
[the answer appears here]
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 02:34 PM
тАО04-03-2009 02:34 PM
Re: calling C from java
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2009 06:58 AM
тАО04-04-2009 06:58 AM
Re: calling C from java
you can also use SWIG, which generates the jackets routines: http://www.swig.org/
SWIG 1.3.31 has been ported on OpenVMS and I have extensively used it without any problem (but not with java...)
JF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2009 03:38 PM
тАО04-05-2009 03:38 PM
Re: calling C from java
Guy thanks for your valuable example to give me a starting point.
SUNNY2$ type snd_snmp.java
class SYSTEMCALL {
public native int SNMPTRAP (String msg);
static {
System.loadLibrary("SNDSNMP_C");
}
public static void main (String[] args) {
System.out.println("This is java ..calling the C routing");
int result = new SYSTEMCALL().SNMPTRAP("TEST TRAP MSG");
System.out.println("for now lets omit this");
}
}
$ javac snd_snmp.java
$ javah -jni "SYSTEMCALL"
$TYPE SYSTEMCALL.H
/* DO NOT EDIT THIS FILE - it is machine generated */
#include
/* Header for class SYSTEMCALL */
#ifndef _Included_SYSTEMCALL
#define _Included_SYSTEMCALL
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: SYSTEMCALL
* Method: SNMPTRAP
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_SYSTEMCALL_SNMPTRAP
(JNIEnv *, jobject, jstring);
#ifdef __cplusplus
}
#endif
#endif
SUNNY2$ type sndsnmp_c.c
#include "SYSTEMCALL.H"
#include
#include
#include
#define size 512
static char cmdbuffer[size];
/* main(int argc, char **argv ) */
JNIEXPORT jint JNICALL Java_SYSTEMCALL_SNMPTRAP
(JNIEnv *env, jobject obj , jstring cmdbuffer) {
int i;
int sts;
char *cmd = "mcr sys$system:tcpip$snmp_trapsnd.exe 0.0 local 0 0 0 -h 10.100.18.245 -v2c 1.3.6.1.6.3.1.1.4.1.0 \"D\"";
strncat (cmdbuffer, cmd,size);
strncat (cmdbuffer, " \"",size);
strncat (cmdbuffer, argv[1],size);
strncat (cmdbuffer,"\"",size);
printf ("%s\n",cmdbuffer);
sts = system(cmdbuffer);
printf( " sts = %%x%08x.\n", sts);
}
SUNNY2$
SUNNY2$ cc /prefix=all/float=ieee/ieee=denorm/defin=JIT_OPTION/names=(short,as_is)
/reent=multithread/includ=SYS$COMMON:[JAVA$142.INCLUDE...] SNDSNMP_C
SUNNY2$ cc /prefix=all/float=ieee/ieee=denorm/defin=JIT_OPTION/names=(short,as_is) /reent=multithread/includ=SYS$COMMON:[JAVA$142.
INCLUDE...] SNDSNMP_C
strncat (cmdbuffer, cmd,size);
.............^
%CC-W-PTRMISMATCH, In this statement, the referenced type of the pointer value "cmdbuffer" is "struct _jobject", which is not compat
ible with "char".
at line number 18 in file DISK$ORACLE:[ORACLE9I]SNDSNMP_C.C;18