Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Javah - Header File Generator 
 

In Java programming we need to implement some native methods. You must be wondering about what's native methods.

 

Javah -  Header File Generator

                         

In Java programming we need to implement some native methods. You must be wondering about what's native methods

Firstly
, The native methods are in pure C code, not C++. The function prototypes are in an object-oriented form of C which are being provided by javah , but they are still not object methods.

Secondly, We can call native methods applications only. However due to some security reasons, we cannot call applets from native methods.

Thirdly,  native methods are platform-specific. This is the most important point to remember, you have to build a dynamically loadable library to link your java application with the native operating system (Windows OS, Machintosh, Linux, Unix ..).  For each native platform your application targets, a dynamically loadable library is needed to be shipped.. That means any system-specific code has to be ported along with the java code.

On the other hand, native methods are the only way to use any system features not provided by the Java Virtual Machine.
To implement these methods Javah generates C header and source files that are used by C programs to reference an Object's instance variables from native source code. The name of the header file and the structure declared within it are derived from the name of the class.

By default javah creates a header file for each class listed on the command line and puts the files in the current directory. As stated above the name of the header file is derived from the name of the class. If any class inside the package is passed to javah, the package name gets prepended to both the header file name and the structure name.

Following are some options to use : 

-o outputfile
This option concatenates the resulting header or source files for all the classes listed on the command line into output file. 

-help
Print help message for javah usage.

-d directory
This option sets the directory where javah saves the header files or the stub files. Only one of -d or -o may be used.

-classpath path
Specifies the path javah used to look up classes. Overrides the default or the CLASSPATH environment variable if it is set. Directories are separated by semi-colons. Thus the general format for path is:
.;<your_path>

For example:
.;C:\users\dac\classes;C:\tools\java\classes

-stubs
Causes javah to generate C declarations from the Java object file.

-verbose
Indicates verbose output and causes javah to print a message to stdout concerning the status of the generated files.

-version
Prints out javah version information.


Back to Java Introduction

                         

» View all related tutorials
Related Tags: java html c mac web com browser class application applet jvm io include sdk view help apple output get virtual

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.