Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Using JNA in Rhino Javascript
Using JNA in Rhino Javascript [message #1062991] Tue, 11 June 2013 16:13 Go to next message
Sohini Chatterjee is currently offline Sohini ChatterjeeFriend
Messages: 1
Registered: June 2013
Junior Member
Hi
I am using CCSv5.3 for a certain project. Can anybody please explain how to use JNA in Rhino Javascript to call C functions from the Javascript code? I read somewhere "JavaScript engine, Rhino is implemented in Java, so there is JNA to do such task." But in the link - the following code was mentioned to call the printf function from C library -

package com.sun.jna.examples;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
/** Simple example of JNA interface mapping and usage. */
public class HelloWorld { // This is the standard, stable way of mapping, which supports extensive
// customization and mapping of Java to native types.
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary((Platform.isWindows()?"msvcrt":"c"),CLibrary.class);
void printf(String format, Object... args); }

public static void main(String[] args)
{ CLibrary.INSTANCE.printf("Hello, World\n");
for (int i=0;i < args.length;i++)
{ CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]); }
}
}

However I cannot understand how to implement this code in CCSV5.3 Rhino console - because Java program will not be supported here.
Please help.
Thanks in advance
Re: Using JNA in Rhino Javascript [message #1063073 is a reply to message #1062991] Wed, 12 June 2013 07:17 Go to previous message
miche clair is currently offline miche clairFriend
Messages: 1
Registered: June 2013
Junior Member
thanks for the information buddy Very Happy
Previous Topic:Having issue while creating an eclipse plugin project
Next Topic:Associating editors with file types
Goto Forum:
  


Current Time: Fri Apr 26 03:55:54 GMT 2024

Powered by FUDForum. Page generated in 0.08193 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top