How to Use native keyword in java programming

Hi ,
I am using JDK 1.6.0_11 , and i was trying to create a java program using "native" keyword ,
i got the sample code for the same from the site : - http://www.javaworld.com/javaworld/javatips/jw-javatip23.html
But when i type this command " C:\javah -stubs Happy " following error occurs
" Error: JNI does not require stubs, please refer to the JNI documentation. "
then typed " c:\javah -jni Happy" without any error .
After that i wrote a HappyImpl.c as mentioned in the above tutorial
#include <StubPreamble.h> /* Standard native method stuff. */
#include "Happy.h" /* Generated earlier. */
#include &ltstdio.h> /* Standard C IO stuff. */
void Happy_printText (struct HHappy *this)
puts ("Happy New Year!!!");
then it is not compling and error is
"unable to open included file StubPreamble.h file
unable to open included file Happy.h file "
Please help me . i want to use native method , i did exactly the same in tutorial at above link.
Thanks & Regards
Mannat

you do need to know how to use your C compiler... It quite clearly can't find those files which indicates that you didn't tell it where to find them.

Similar Messages

  • Can i make Thread safe without using synchronised keyword in java

    Hi all,
    please tell me code and concept that we can make Thread safe without using synchronised keyword in java programming.
    regards
    Mohan kumar

    There's a series of new features in Java 5.0 (JDK 1.5.0) to address things like concurrency.
    See: http://java.sun.com/j2se/1.5.0/docs/guide/concurrency/overview.html
    -Alexis

  • Help--How can I open only one java program at one time?

    How can I open only one java program(same program) in Windows at one time?

    In Java 1.5, you can use the JVM's own monitoring APIs to examine what other JVMs are running on the system, and what applications they're running.
    It's general and powerful, but complex. The socket/file/whatever approach is cleaner, and probably more suited to your usage.
    Don't bother trying to use the Windows task manager for this sort of thing. You have to write messy native code, and it isn't reliable after all that anyway.

  • How to change system time through java program

    Hi
    I want to know, how to change system time through java program.
    give me a idia with example.
    Thanks

    There isn't any core Java API for this. Use JNI or call an external process with Runtime.exec().
    ~

  • How to use native method

    how to use native methods

    ----- BEGIN CANNED RESPONSE -----
    Download and read Sheng Liang's book, ftp://ftp.javasoft.com/books/specs/jni.pdf
    Read the JNI specs on java.sun.com site ( http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html )
    Beware with the JNI tutorial on the java.sun.com site - it is slightly outdated, and the samples need modifications to compile
    ----- END CANNED RESPONSE -----

  • How to use C-Structure in java applets

    hi alls,
    I want to use a struct model (struct in C++) in java applets. i know class is used in java applications. but, how can i convert in java applets?
    class renk
    int r;
    int gr;
    int b;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.Event;
    import java.applet.Applet;
    public class benek extends Applet
    final int n=10;
    int x[] = new int[n];
    int y[] = new int[n];
    int count = 0;
    renk clr[] = new renk[n];
    public void init()
    setBackground(Color.black);
    public boolean mouseDown(Event yordam, int xyer, int yyer)
    if (count<n)
    System.out.println("...");
    ekle(xyer,yyer);
    else System.out.println("Kapasite Doldu...");
    return true;
    void ekle(int xyer, int yyer)
    int r1 = (int)Math.floor(Math.random()*256);
    int gr1 = (int)Math.floor(Math.random()*256);
    int b1 = (int)Math.floor(Math.random()*256);
    clr[count].r = r1;
    clr[count].gr = gr1;
    clr[count].b = b1;
    x[count]=xyer;
    y[count]=yyer;
    count++;
    repaint();
    public void paint(Graphics g)
    it gives error message... how can � use struct model in java applets???
    if you help me i will be greatfull....

    � use import but it doesn't work.
    i add: import renk; or import class renk;
    how will � add import I assumed based on your initial post that the renk and benek classes were in the same file. Apparently you're saying they are not. So for another thing, make your renk class "public class renk", and add the "public" keyword to the 3 members of that class. Then if your code still doesn't see the "renk" class, it would just be that you don't have the directory that contains the compiled "renk.class" in your classpath.

  • How to use sql query in java ?

    i don't know how to use sql query in java code.
    who can give me some advice?
    thanks

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • How to use " toFront() " method in java application and in which package or

    How to use " toFront() " method in java application and in which package or class having this toFront() method.if anybody know pl. send example.

    The API documentation has a link at the top of every page that says "Index". If you follow that and look for toFront(), you will find it exists in java.awt.Window and javax.swing.JInternalFrame.
    To use it in a Java application, create an object x of either of those two classes and write "x.toFront();".

  • How to use XML / XPath in JAVA (in 1.4) which third part component to use?

    How to use XML / XPath in JAVA (in 1.4)
    I'm absolutely novice in XML
    but I need to query XML using XPath
    As I understand XPath become avalible only in Java 1.5
    But I use 1.4 (project requirement)
    Which third part component could you recomend?

    Can anyone help me with this XPath query
    I get result [title: null]
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.w3c.dom.*;
    import org.jaxen.*;
    import org.jaxen.dom.*;
    import org.jaxen.saxpath.*;
    import java.util.*;
    public class TestX {
         public void ggg() {
              try {
                   File f = new File("journal.xml");
                   DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                   org.w3c.dom.Document doc = docBuilder.parse(f);
                   XPath xpath = new DOMXPath( "/journal/article/title" );
                   List result = (List) xpath.evaluate(doc);
                   System.out.println(result.get(0));
              } catch (Exception e) {
                       e.printStackTrace();
         public static void main(String[] args) {
              TestX tx = new TestX();
              tx.ggg();
    }journal.xml
    <journal>
        <article id="article.1">
            <title>Art1</title>
            <author>
               <first>Bob</first>
               <last>McWhirter</last>
            </author>
            <text>
            </text>
        </article>
        <article id="article.2">
            <title>Art2</title>
            <author>
               <first>James</first>
               <last>Strachan</last>
            </author>
            <text>
            </text>
        </article>
    </journal>

  • Can't use certain characters in java programs.

    For some reason I cannot use characters like: " ^ ~ | " in java programs.
    I can type them in a terminal and then paste them into the program, but cannot type them inside the java program - It's has been like that in every java application I have used. It only works when typing them in a applet running on a browser.
    Im running Linux RH 7.2 with JDK1.4.0 (It works fine in windows 2000)
    Hope somebody can help me.
    /Tommy

    Ehmm. What makes you believe that it isnt?
    I can't make exclusiveOr operations and if(bubba || bubba2) something....And that is a problem / annoyance.
    I can type every other characters but those ��� works fine as well.

  • How to use openjpa  + kodo in Java SE?

    Hi.
    We are developing J2EE application on Weblogic Server 9. For a part of application we should create unit tests that will be run in Java SE. How to use openjpa + kodo in Java SE?

    Hi,
    Try the EclipseLink JPA JEE5/JEE6 provider - it has been shipping as part of WebLogic Server since 10.3.1.0.
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    The following page has several SE, application-managed and container-managed EE example tutorials with source.
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial
    http://wiki.eclipse.org/EclipseLink/Examples/JPA
    The following forum will help you with any JPA specific issues.
    Forum: TopLink/JPA
    TopLink/JPA
    thank you
    /michael
    http://www.eclipselink.org

  • How can I use MS Word within java programming

    Hi everyone!
    I am developing a Java program that will take data
    from an Access 2000 database, and manipulate it,
    display the results graphically and in tables. The
    challenge for me is that I want the program insert the
    graphics and tables into the MS Word template and then
    prompt me to save it as a word * .doc. Do you know
    of any articles or sources of sample code on how to do
    this. The Java environment is Java2, JDK 1.3,
    JBuilder4. The OS environment is XP.
    Regards,
    Farad

    Hi, I also need that package. my e-mail is [email protected] Plese send me that. Thanks in advance
    I have a package that will do this for you. I just
    need to get your email to send an attachment and
    examples.

  • How to access system registry through java program

    Friends
    I have to access System registry of Windows 2000 by Java program. I don't know how to access the registry by using java code. Please help me. Else
    I want to create a setup file for my application. before setup my application i have to check whether the system has JVM or not. If its not then i have to install JVM first and then my application. so i need to access system registry. please give me a solution for this.
    Thanks in advance
    Ramesh

    I don't know how to access the registry
    by using java code. You can't, without using a native interface (JNI type) library.
    This is one, there are others, do a Google search:
    http://www.bayequities.com/tech/Products/jreg_key.shtml

  • How to run sscript shell with java program

    Hi everybody,
    i want to know how can i do to execute a script shelle (bash) with program java (if it s possible)
    for example this script:
    #!/bin/bash
    echo "hello"
    can i run it with java program or i have to make dome modifications .
    thank you for your help in advance.

    Well, if you want to be portable across platforms, you should write as much code in Java as possible and not rely on native scripts (I'm sure your script is more complex than this 'echo' example ;-) ).
    Having said that, you can use the java.lang.Runtime class and in particular its various exec() methods.
    Try something like this:
    Process p;
    try {
        p = Runtime.getRuntime().exec("myscript.sh");
    } catch (IOException ioe) {
    }You can then "interact" with the spawned process with the Process object returned by the exec method.
    Note you need to have the appropriate security rights.
    For more details, look at the API documentation here:
    http://java.sun.com/j2se/1.4.2/docs/api/
    hth,
    -Alexis

  • How to pass native struct to java

    Hey guys,
    I've got a legacy C++ prog that outputs structs to a binary file & I've got a header file defining that struct.
    I want to read the file and get the structs via java but I've never used any interface between the languages.
    All I've managed to come up in my searches is "how to pass java objects to c", well how do I do the opposite?
    Help appreciated

    I hear you calling me :)
    If this interests you I'll explain the problem from the beginning-
    I already have a C prog which outputs a HUGE binary file (therefore text is probably not a good idea),
    this file consists of a header followed by some number (defined in the header) of a certain struct (consisting of ~20 fields ints, longs, strings...)
    Another C program exists that reads this file. I am currently building some sort of visual interpretation of the data using java.
    As all C code is quite heavy duty [and works like it should :)], and a few other reasons, I do not want to change it.
    That leaves me with an existing file containing binary data I need to read into the Java UI.
    sztejkat > Why use native code?
    I would have really wished I could do this entirely in Java, as for portability - it doesn't have much consideration, just in terms of "clean" programming.
    As you said struct packing is something unpredictable, therefore I do not see a way of reading one without using C.
    bschauwejava > I suggest you try to be less vague about the results you are getting.
    Sorry :)
    This is the structure: File (package) -> File.java, InsInfo.java (classes)
    I'm using "javac File.java"
    And I'm getting:
    File.java:3: cannot resolve symbol
    symbol : class InsInfo
    location: package File
    import File.InsInfo;
    ^
    File.java:20: cannot resolve symbol
    symbol : class InsInfo
    location: class File.File
    public native InsInfo readIns();
    ^
    2 errors
    (the arrows actually point to the first letter in the class name)
    If I use "Object" instead of "InsInfo" javac compiles the .class without problems.
    I'm using Jbuilder and inside it the import is OK. When I compile it with Jbuilder everything is OK.
    I actually haven't thought of this until now, I'll try to use the .class Jbuilder produces to generate the header.
    btw- Thanks for getting so involved!!

Maybe you are looking for

  • How to get the files related to a module from server

    Hi, I am facing a problem. i have to extends controller but it has lot of imports from the same module but different folders. and all the files are in .class files. Can you tell me a process where i can download onto my local system from the server a

  • Can I spedify the SMTP to use for Password Reset Service?

    I'd like to be able to specify what mail server to use when access manager is sending out mail. The password reset service is currently looking to localhost, port 25 for the mail server when trying to send out mail. Is it possible to change this? Tha

  • Where can I find the field "Code" in PPOMA_CRM? what table?

    Hi Experts, I need to extract the Organizational Structure from PPOMA_CRM to BW. I know HRP1000 and HRP1001 are the main tables related to this transaction code, but I think they are not enough to suit my requirements. My OS tree is: Country->Region-

  • PS CS5 update error

    I had to reinstall Win7 and PS CS5, and the updates fail to install. I opened PS with right-click-run-as-admin, that did not help. Why? Thanks Tom

  • [solved] cannot install pacstrap /mnt base to UEFI without internet

    Hello everybody. Today I decided to install ArchLinux because of some problems on my Linux Mint System. On my laptop Lenovo yoga 13  while using Mint I installed Wi-Fi drivers after installation. It is not working out of the box. There is no Ethernet