Monday, July 20, 2009

7 Cm Renal Cyst Kidney

Accessing native methods (JNI vs. JNA) Restructuring the Blog

.

This chapter is being developed, may contain errors .

Java provides the ability to access functions written in C through what is called "native methods." There are currently two technologies through which we can call C functions from our Java programs. These are:
  • JNI - "Java Native Interface (conventional technology), and
  • JNA -" Java Native Access "
While both allow you to access C functions from Java, the methodology is very different . JNI is extremely more complex than JNA.

This chapter will develop some examples in both technologies with the objective to understand how they could be used and compared.


HelloWorld - Use JNI JNI

is somewhat cumbersome. Below I will list the steps to be performed to invoke a C function that prints "Hello World" in the console.

If the reader believes that this is very difficult or complicated to follow him until the end I recommend you go straight to the implementation developed with JNA exposed below.

1 - Define a Java class with native methods

CLib.java (class with native methods)
   1:  
2: demo.jni package;
3:
4: public class Cliba
5: {
6: / / the methods native not be develop
7: public native void HelloWorld ( ) ;
8: }
9:


2 - Compile the. Java before and then run the command javah to generate the . h with the C headers that correspond to the native methods defined in the class.

javah-jni demo.jni.CLib

We should note that to run this command from the command line we have seteado the PATH to% JAVA_HOME% \\ bin and must be positioned in the parent directory or demo package While we must have the CLASSPATH set correctly.

javah command should generate the following file:

demo_jni_CLib.h
   1:   / *          DO         NOT         EDIT         THIS         FILE         -         it         is         machine         generated         */   
2: # include < jni.h >
3: /* Header for class demo_jni_CLib * /
4:
5: # ifndef _Included_demo_jni_CLib
6: # define _Included_demo_jni_CLib
7: # ifdef __cplusplus
8: external " C" {
9: # endif
10: / *
11: * Class: demo_jni_CLib
12: * Method: holaMundo
13: * Signature: ()V
14: */
15: JNIEXPORT void JNICALL Java_demo_jni_CLib_holaMundo
16: ( JNIEnv *, jobject ) ;
17:
18: # ifdef __cplusplus
19:
} 20: # endif
21: # endif
22:


3 - Programming in C native method implementation HelloWorld using the header we got after running the command javah.

demoJNI.c
   1:  
2: # include < stdio.h >
3: # include < jni.h >
4: # include " demo_jni_CLib.h "
5:
6: JNIEXPORT void JNICALL Java_demo_jni_CLib_holaMundo ( JNIEnv * env , jobject obj )
7: {
8: printf ( " Hello World \\ n " ) ;
9:
} 10:


4 - Compile the C code and generate a DLL. If we use MinWG the command is as follows:

gcc-c-I% JAVA_HOME \\ include-I% JAVA_HOME% \\ include \\ win32 demoJNI.c
gcc-shared-o demoJNI.dll
demoJNI.o
This generates the file demoJNI.dll.


5 - Write a program that instantiates the class and invoke the method Cliba HelloWorld.

Demo.java
       1:   
2: package demo.jni;
3:
4: public class Demo
5: {
6: public static void main ( String[] args )
7: {
8: System. loadLibrary ( " demoJNI " ) ;
9: CLib clib = new Cliba ( ) ;
10: clib. HelloWorld ( ) ;
11:}
12:}
13:

More information: http://java.sun.com/ docs / books / jni / html / start.html

Hello World - JNA

The approach provides JNA is more intuitive, simple and direct. We just need to download the file jna.jar .

1 - JNA began to write the C code header unconditionally with any stranger.

demoJNA.c
   1:  
2: # include \u0026lt;stdio.h >
3: void HelloWorld ( )
4:
{5: printf ( " Hello World \\ n " ) ;
6:
} 7:


2 - The next step is to create a Java interface that defines the HelloWorld method that "wrappea" function written in C.

CLib.java
   1:  
2: demo.jna package;
3:
4: import com.sun.jna.Library;
5 :
6: public interface extends Cliba Library
7: {
8: public void HelloWorld ( ) ;
9:
} 10:


3 - Finally we can write the main program that invokes the interface HelloWorld Cliba.

Demo.java
   1:  
2: demo.jna package;
3:
4: import com.sun.jna.Native;
5 :
6: public class Demo
7: {
8: public static void main ( String [] args )
9: {
10: Cliba = clib ( Cliba ) Native. LoadLibrary ( " demoJNA " , Cliba. class ) ;
11: clib. HelloWorld ( ) ;
12:}
13:}
14:

More information: https: / / jna.dev.java. net /












.

Sunday, July 12, 2009

Guys Underwear Stories



Associates Lawyers involved as volunteers on the web WWW.TODOEXPERTOS.COM with expert called "lawyers" to solve quickly the most common and pressing questions that everyone needs and free.

http://www.todoexpertos.com/categorias/humanidades/derecho/derecho-laboral/expertos/juristas/respuestas

Saturday, July 4, 2009

Clear Blister Bubble In Mouth

TodoExpertos Unemployment among autonomous

Efe - Gijón - 14/02/2009
Barreda, who has participated in Gijón in a conference organized by the Socialist Federation of Asturian (FSA-PSOE) on this employment scheme, explained to Efe that the Government has received the proposal to charge a group of experts.

The document has been referred to the social and throughout this year, the central government establish its own initiative, agreed with contributions from unions. The head of the autonomous work has emphasized that in Currently, only listed professionals to qualify for retirement and disability, so that during 2010 should contribute to Social Security for twelve months after the start to be paid unemployment compensation.

"It must be economically sustainable," he defended Barreda, who emphasized that the measure can not be expedited. It has also announced that the Council of Ministers approved on Friday a decree for the entry into force of the regime economically dependent autonomous workers (TRADE), which require companies to contribute at least 75 percent of the income of a self- the signing of a contract that provides "legal certainty."

Thus, it is mandatory to provide a minimum of 18 vacation days may be requested compensation for the cessation of business and labor disputes are handled by the courts of Social, more agile than commercial. Barreda has explained that the Government has launched an initiative for unemployed people who lose their jobs to spend sixty percent of their unemployment benefit to the implementation of a free-lance business and the remaining forty percent payment of Social Security benefits.

commented that, according to data obtained in December 2008, 255,000 young people have benefited from lower thirty percent of the price for children under 35, apply for a year and a half. The manager has said that self-employed workers are hardest hit by the current economic situation and stressed that the rising unemployment rate is half that in the regime of employees.