- 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-05-2009 08:38 PM
тАО04-05-2009 08:38 PM
Re: calling C from java
You have:
static char cmdbuffer[size];
JNIEXPORT jint JNICALL Java_SYSTEMCALL_SNMPTRAP
(JNIEnv *env, jobject obj, jstring cmdbuffer) {
Your parm name cmdbuffer hides your file scope definition.
If you were using a real language like C++, you could just use ::cmdbuffer to access the global scope. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2009 10:15 PM
тАО04-05-2009 10:15 PM
Re: calling C from java
cu,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2009 11:58 PM
тАО04-05-2009 11:58 PM
Re: calling C from java
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 07:49 AM
тАО04-06-2009 07:49 AM
Re: calling C from java
static char cmdbuffer[size];
/* main(int argc, char **argv ) */
JNIEXPORT jint JNICALL Java_SYSTEMCALL_SNMPTRAP
(JNIEnv *env, jobject obj , jstring msg) {
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\"";
char buf[512];
const jbyte *str;
str = (*env)->GetStringUTFChars(env, msg, NULL);
if (str == NULL) {
return NULL; /* OutOfMemoryError already thrown */
}
printf("%s", str);
(*env)->ReleaseStringUTFChars(env, msg, str);
/* 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);
*/
return 0;
}
$link/share=sndsnmp_c sndsnmp_c,sndsnmp_c/opt
$ JAVA "SYSTEMCALL" "testing"
Warning: JIT compiler "SUNCOMPILER" not found. Will use interpreter.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no SNDSNMP_C in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1578)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 07:52 AM
тАО04-06-2009 07:52 AM
Re: calling C from java
SUNNY2$ type sndsnmp_c.opt
case_sensitive=YES
symbol_vector=(Java_SYSTEMCALL_SNMPTRAP=PROCEDURE)
case_sensitive=NO
java$java_shr/share
gsmatch=lequal,1,1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 08:03 AM
тАО04-06-2009 08:03 AM
Re: calling C from java
is the function of the libgesyi logical pointing to the shared image ? I didnt define any such logical, is this the reason iam getting error? how is this logical name constructed ?
$ link/share=getjpi_shr.exe getjpi_nat.obj,getjpi.opt/opt,java.opt/opt
$ link/debug/share=getjpi_g_shr.exe getjpi_nat.obj,getjpi.opt/opt,java_g.opt/opt
$
$ define/nolog libgetsyi sys$disk:[]getsyi_shr.exe
$ define/nolog libgetsyi_g sys$disk:[]getsyi_g_shr.exe
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 08:22 AM
тАО04-06-2009 08:22 AM
Re: calling C from java
SUNNY2$ link/share/exec=java$sndsnmp_c_shr.exe sndsnmp_c,sndsnmp_c/opt
SUNNY2$ def/job/log java$sndsnmp_c_shr sys$login:java$sndsnmp_c_shr.exe
SUNNY2$ JAVA "SYSTEMCALL" "TESTING"
Warning: JIT compiler "SUNCOMPILER" not found. Will use interpreter.
This is java ..calling the C routing
@├В┬▓UP├В┬▓U├Г `U├о┬д┬╗U0l├Е┬╕z;l├Е┬╕z├о┬д┬╗6for now lets omit this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 08:57 AM
тАО04-06-2009 08:57 AM
Re: calling C from java
any ideas why iam getting those special characters instead of the string that iam inputting as parameter?
<<<
Because you're not using it?
- The jstring parameter msg is probably not UTF8 encoded. That's why I suggested GetStringChars and not GetStringUTFChars.
- The jbyte variable str is not a null-terminated C string. That's why I suggested using GetStringLength
cu,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 09:07 AM
тАО04-06-2009 09:07 AM
Re: calling C from java
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 09:08 AM
тАО04-06-2009 09:08 AM
Re: calling C from java
jstring jstr;
jstr = (*env)->NewStringUTF(env, result);
if (jstr == NULL) {
fprintf(stderr, "out of memory");
return 0;
}
printf("%s","now in C routine");
printf("%s", jstr);