Hello World in JNI

Discussion in 'Java' started by maurizio, Jul 25, 2003.

  1. maurizio

    maurizio Guest

    I'am very bad working with program but I love java programming and i want to
    make my first program in JNI but I have a big trouble in this part of the
    process.

    This is the part of the java tutorial explains the way to build the .dll
    **********
    On Win32, the following command builds a dynamic link library hello.dll
    using Microsoft Visual C++ 4.0:

    cl -Ic:\java\include -Ic:\java\include\win32
    -LD HelloWorldImp.c -Fehello.dll

    Of course, you need to specify the include path that corresponds to the
    setup on your own machine.
    *************
    I dont't understand the first line of the code and what means include is the
    setup on my own machine. The set up of what machine?
    I have not Microsoft Visual C++ 4.0 in my Windows 98.
    I have only Microsoft.VisualC.Dll in my machine but I don't know if it's the
    same

    I don't understand why the name of the lib is -Fehello.dll


    Could someone help me?


    Regard Maurizio
     
    maurizio, Jul 25, 2003
    #1
    1. Advertising

  2. On Fri, 25 Jul 2003 12:23:22 GMT, "maurizio" <> wrote:

    >I dont't understand the first line of the code and what means include is the
    >setup on my own machine. The set up of what machine?


    your machine. you need to provide paths to <path of jdk>/include and
    <path to jdk>/include/win32 in order to compile C/C++ code written so
    that can be used through JNI

    >I have not Microsoft Visual C++ 4.0 in my Windows 98.


    if you want to compile C source code to use with Java via JNI you have
    to install a C compiler.

    >
    >I don't understand why the name of the lib is -Fehello.dll
    >


    you should look at the documentation of the microsoft visual c++
    compiler to understand that parameter. The example for windows is
    written using that compiler.

    ciao
    --
    Seti@Home Java Applets
    http://maruko.webhop.net/
     
    Marco Parmeggiani, Jul 25, 2003
    #2
    1. Advertising

  3. "maurizio" <> schrieb im Newsbeitrag
    news:_i9Ua.13491$...

    Hi Maurizio,

    > I'am very bad working with program but I love java programming and i want

    to
    > make my first program in JNI but I have a big trouble in this part of the
    > process.
    >
    > This is the part of the java tutorial explains the way to build the .dll
    > **********
    > On Win32, the following command builds a dynamic link library hello.dll
    > using Microsoft Visual C++ 4.0:
    >
    > cl -Ic:\java\include -Ic:\java\include\win32
    > -LD HelloWorldImp.c -Fehello.dll
    >
    > Of course, you need to specify the include path that corresponds to the
    > setup on your own machine.
    > *************
    > I dont't understand the first line of the code and what means include is

    the
    > setup on my own machine. The set up of what machine?
    > I have not Microsoft Visual C++ 4.0 in my Windows 98.
    > I have only Microsoft.VisualC.Dll in my machine but I don't know if it's

    the
    > same
    >
    > I don't understand why the name of the lib is -Fehello.dll


    I never used VC++ 4.0. That´s a quite old version.I´m using VC++6.0 or VC++
    ..NET (don´t booh at me newsgroup - it´s just the name .Net ;) ) I guess the
    name Fehello comes from some makefile. In order to create your own DLL, you
    will need a C/C++ compiler installed on your system. The runtime DLL of MSVC
    won´t help you much. There´s a quite good JNI tutorial at Sun´s website you
    might want to have a look at.

    Regards,
    Joerg
     
    Joerg Gippert, Jul 25, 2003
    #3
  4. maurizio

    Roger Irwin Guest

    JNI is for calling routines you have developed in C. When compiling the
    C program file (called HelloWorldImp.c), it needs to be linked with some
    java libraries (which is what is on the first line), then the output
    file generated is hello.dll.

    Basically, these are instructions for created a C program that can be
    called from Java, if you are not familiar with this I suggest you do not
    try using the JNI. First learn Java programming, then C programming,
    THEN try and put it together.

    At the end of the day JNI is generally required only for specialist uses
    such as implementing custom DSP filters in multemedia apps. For the most
    part you should be able to find excellent implementations that allready
    exist!


    maurizio wrote:
    > I'am very bad working with program but I love java programming and i want to
    > make my first program in JNI but I have a big trouble in this part of the
    > process.
    >
    > This is the part of the java tutorial explains the way to build the .dll
    > **********
    > On Win32, the following command builds a dynamic link library hello.dll
    > using Microsoft Visual C++ 4.0:
    >
    > cl -Ic:\java\include -Ic:\java\include\win32
    > -LD HelloWorldImp.c -Fehello.dll
    >
    > Of course, you need to specify the include path that corresponds to the
    > setup on your own machine.
    > *************
    > I dont't understand the first line of the code and what means include is the
    > setup on my own machine. The set up of what machine?
    > I have not Microsoft Visual C++ 4.0 in my Windows 98.
    > I have only Microsoft.VisualC.Dll in my machine but I don't know if it's the
    > same
    >
    > I don't understand why the name of the lib is -Fehello.dll
    >
    >
    > Could someone help me?
    >
    >
    > Regard Maurizio
    >
    >
     
    Roger Irwin, Jul 25, 2003
    #4
  5. On Fri, 25 Jul 2003 12:23:22 GMT, "maurizio" <> wrote:

    > I'am very bad working with program but I love java programming and i want to
    > make my first program in JNI but I have a big trouble in this part of the
    > process.
    >
    > This is the part of the java tutorial explains the way to build the .dll
    > **********
    > On Win32, the following command builds a dynamic link library hello.dll
    > using Microsoft Visual C++ 4.0:
    >
    > cl -Ic:\java\include -Ic:\java\include\win32
    > -LD HelloWorldImp.c -Fehello.dll
    >
    > Of course, you need to specify the include path that corresponds to the
    > setup on your own machine.
    > *************
    > I dont't understand the first line of the code and what means include is the
    > setup on my own machine. The set up of what machine?


    -I tells the MS compiler where to find header files. In this
    case the instructions are telling you to tell the compiler
    where your jni.h header is (along with others). jni.h is
    provided by the JDK in the JDK's include directory, but since
    they (the tutorial's authors) have no idea where you installed
    your JDK, they are just telling your to supply the path that is
    correct for your local setup.

    > I have not Microsoft Visual C++ 4.0 in my Windows 98.


    You will need a valid C compiler for Win32. While the tutorial
    uses Visual C++ 4.0, any compiler capable of creating a DLL can
    be used, but you will have to supply equivalent commands. I
    use Visual C++ 6.0 and the commands are the same.

    > I have only Microsoft.VisualC.Dll in my machine but I don't know if it's the
    > same


    No idea what you're saying here.

    > I don't understand why the name of the lib is -Fehello.dll


    -Fe is simply the option that tells the compiler what the name
    of the created module should be. It's used very commonly to
    force a particular name that is different from the one the
    compiler would choose by default. In this case, the dll
    created will be called "hello.dll". If the -Fe option had
    not been provided, the name would have been "HelloWorldImp.dll"

    I get the feeling you are not familar with C or C++ from your
    post. If that's true you should do some basic learning on
    how to propgram in C and C++ and how to use the various tools
    provided by your compiler. FOrgive me if I'm wrong.

    -Joe
     
    Joseph Millar, Jul 26, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carl
    Replies:
    4
    Views:
    418
    Peter Hansen
    May 21, 2004
  2. Daniel Crespo
    Replies:
    5
    Views:
    408
    Amaury
    Nov 13, 2005
  3. vijay
    Replies:
    8
    Views:
    713
  4. Roy
    Replies:
    6
    Views:
    619
    Roedy Green
    Jan 7, 2008
  5. Larry
    Replies:
    27
    Views:
    428
    Michele Dondi
    Jan 25, 2005
Loading...

Share This Page