Progblems Running a C program with JNI on Linux

Hi
We are having a problem running a C program which uses JNI to start a virtual machine.
We can compile it up ok and it finds all the correct libraries and everything is fine as far as we are aware but when we try to run the program the error we get is "command not found". Now when the same programm is compiled with out JNI stuff, so basically no java at all it compiles and runs ok.
I was wondering if anyone else has had similar problems we are using sun jdk 1.3.1 and RedHat Linux 7.2.
Thanks
Iain

Hi
We are having a problem running a C program which uses
JNI to start a virtual machine.
We can compile it up ok and it finds all the correct
libraries and everything is fine as far as we are
aware but when we try to run the program the error we
get is "command not found". Now when the same
programm is compiled with out JNI stuff, so basically
no java at all it compiles and runs ok.
I was wondering if anyone else has had similar
problems we are using sun jdk 1.3.1 and RedHat Linux
7.2.
Thanks
IainHi !
I think I had the same problem. But fortunately I found the solution.
I tried to compile and run the standard sun example of invocation interface. My C file is main.c.
Compilation:
cc -I/usr/java/jdk1.3.1/include/linux -L/usr/java/jdk1.3.1/jre/lib/i386/classic/ -L/usr/java/jdk1.3.1/jre/lib/i386/native_threads/ -lpthread -lhpi -ljvm main.c
after then You must create the environment variable LD_LIBRARY_PATH and point out Your JNI libraries location. That works with mine.
LD_LIBRARY_PATH=/usr/java/jdk1.3.1/jre/lib/i386:/usr/java/jdk1.3.1/jre/lib/i386/native_threads:/usr/java/jdk1.3.1/jre/lib/i386/classic;export LD_LIBRARY_PATH
Now it should work.

Similar Messages

  • How can i run my java program with out java language

    Hai to every one ..Iam new to java language ...am using windows xp operating system , i did not installed java language in my system .. how can i run a java program with out installing java language... Which files is requied to run java program..?
    any one can help me??

    Hai to every one ..Iam new to java language ...am
    using windows xp operating system , i did not
    installed java language in my system .. how can i run
    a java program with out installing java language...
    you ... can ... not ... do ... this
    Which files is requied to run java program..?
    any one can help me??a JVM. Download it from sun's website.
    [url http://java.sun.com/javase/downloads/index.jsp]Download JavaSE here

  • Running a Java program at startup in Linux

    Hello
    How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
    Thank you,
    Mihai

    This is really a Linux question, not Java.
    And then it depends on the version of Linux you are using.
    Maybe this will help, otherwise you should try on a forum for your version of Linux.

  • Why can't I run my Java program with just the JRE, the JDK is required?

    I've recently written 3 programs in Java using the Netbeans IDE with JDK 1.6 as the default Java platform. The compile-time libraries include the Swing Application Framework. I use BuildDesk from ProductiveMe to package the each program into a Windows installer.
    When I install the programs on a new computer without a JRE or JDK being present, and attempt to run them I get an error (as expected) stating that there is no JVM. The messages says that I need to install JDK 1.3 or higher. I downloaded the latest JRE onto the new computer and attempted to run the programs and I get the same error message. My question is, why can't I run these programs with just the JRE installed? Why do I need the JDK? When I install the JDK, the programs run fine. The typical user may not have the JDK on their system, but they likely have the JRE if they've run Java programs before.
    Is the answer as simple as there must be library functions being used by the programs that belong to the JDK, but not the JRE? I'd rather a user not have to install the JDK verses the JRE because they may also have to update some Windows environment variables.
    Thank you for any help on this issue.

    915088 wrote:
    Thanks for your replies. I further investigated BuildDesk and found an option which allows a JVM check but that check needs the JDK. I stopped the JVM check and rebuilt using BuildDesk and it now only requires the JRE to run the programs. The reason why I use BuildDesk is to package more than just the jar file for the user. BuildDesk allows me to create a installation folder structure as well as include any other files in the build. I could just as well zipped all this together for the user but decided against that method.I don't think anyone will question your usage of an installer tool; that is entirely up to you. But what is questionable is that you have problems with that installer tool and then go look for help in a Java programming forum. The next time, go look for help at the source. If there is no way to acquire help (support, a forum, a mailinglist, anything) then that is a very good reason to not use the product in question.

  • Running a GUI program with no X?

    Hi,
    I want to run a GUI program on my server, which has no X installed. Of course, the program would normally not run since it needs X (GUI only). I don't really need to be directly using this software, it just needs to run. Anybody here knows if there is any way to fool it into thinking X is there, so it'll still run on my server, preferably as a service in the background?
    PS
    I probably need the same thing for sound too, no alsa or pulse either.
    Any  help's appriciated.

    I probably owe you guys an explanetion: The program in question is Skype. I'm sick and tierd of having skype steal recources when all my other IMing is done in bitlbee. That's why I came up with the following solution: I've done some reading, and turns out skype has a bitlbee plugin.
    However, that plugin uses the skype API which means I can't get around having skype. So, I decided to try the following setup: Run a bitlbee server from my home server. Have skype sorta just run in there doing nothing, and use the bitlebee plugin so I can connect with my own computer and use skype with bitlbee (Note: this is so I can chat with friends, not so I can video / audio chat so I don't care about those features). Basicly that was my idea and i'm exploring the posibility. Skype sadly has no deamon mode, but it does offer a shell pipe login so I'll start skype in my server, and do that setup. Of course now that I see i'll need to install x no matter what i'm not sure if it's worth it. I don't need X on my server for any other purpuse and X will steal recources from my server. I do however love not needing a skype client nativly. Anyone has any experiance / ideas / advice about my idea?
    Stalafin wrote:
    Greenstuff wrote:
    Hi,
    I want to run a GUI program on my server, which has no X installed. Of course, the program would normally not run since it needs X (GUI only). I don't really need to be directly using this software, it just needs to run. Anybody here knows if there is any way to fool it into thinking X is there, so it'll still run on my server, preferably as a service in the background?
    PS
    I probably need the same thing for sound too, no alsa or pulse either.
    Any  help's appriciated.
    Wut? You want to output sound without anything that is able to output sound? Is it me or is that just plain weird....? o.O
    I realize it sounds comfusing but Skype needs somewhere to dump sound apperantly (I found that out on my resharch). So I need a way to fool it into thinking there's such a device.
    Last edited by Greenstuff (2009-11-03 21:24:29)

  • Running a java program with eclipse

    Hi,
    I'm trying to run this java program(below) in eclipse..when i go to the 'run' icon inorder to choose the option 'run as' then 'java application' , i have 'none applicable' as the only option available. is it possibly because the program uses threads?
    could someone using eclipse please try to execute this program and let me know if you succeed and how exactly you do it.
    package reseaux;
    import java.io.*;
    import java.net.*;
    import java.util.*;
         public class LeServeur extends Thread{
         Socket socket;
         BufferedReader in;
         PrintWriter out;
         Vector FlowList=new Vector(10);
         public LeServeur(Socket socket)throws IOException{
              this.socket=socket;
              in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
              out= new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
         public void run(){
              String s;
              synchronized(FlowList){
                   FlowList.addElement(this);
              try{
                   while(!(s = in.readLine()).equalsIgnoreCase("/quit")){
                        for(int i=0;i<FlowList.size();i++){
                             synchronized(FlowList){
                                  LeServeur monServeur=(LeServeur)FlowList.elementAt(i);
                                  monServeur.out.println(s + "\r");
                                  monServeur.out.flush();
              catch(IOException e){
                   e.printStackTrace();
         finally {
         try {
              in.close();
              out.close();
              socket.close();
         } catch(IOException ioe) {
         } finally {
              synchronized(FlowList) {
              FlowList.removeElement(this);
    thanks

    thanks...
    Infact, i wanted to run the main program called 'Serveur' but it uses 'LeServeur'( the code i sent before') and apparently it gives me an error msg that it doesnot recognise the 'LeServeur'...that's why i was thinking that i should probably first compile the 'LeServeur' so that it can be recognised in the 'Serveur' program.
    here is the 'Serveur' code that uses an instantiation of the LeServeur...
    package reseaux;
    import java.net.*;
    import java.io.*;
    public class Serveur {
              public int port;
              public ServerSocket skt;
              public Socket socket;
         public static void main(String[] args) {
              int port=8975;
              ServerSocket skt=null;
              Socket socket=null;
              try{
                   if(args.length>0)
                        port=Integer.parseInt(args[0]);
              catch(NumberFormatException n){
                   System.out.println("This port is used uniquely for listening");
                   System.exit(0);
              try{
                   skt= new ServerSocket(port);
              while (true){
                   socket =skt.accept();
                   LeServeur flow=new LeServeur();
                   flow.start();
         catch(IOException e){
              e.printStackTrace();
         finally{
              try{
                   skt.close();
              catch(IOException e){
                   e.printStackTrace();
    do you know have any idea why it doesnt recognise the 'LeServeur'?
    ps:they're in the same package
    thanks

  • Calling an existing C code with JNI under linux.

    Hi all,
    I am trying to use an exsiting c code with jni but I am keep getting
    java.lang.UnsatisfiedLinkError, I am working under linux.
    This is what I have done so far:
    1.export LD_LIBRARY_PATH='pwd'/lib
    2. created HspellNative.java with the static System.loadLibrary("HspellNative") and native function called hspellInit
    3. compiled the java class
    4. javah -jni HspellNative
    5. HspellNative.c:
    #include <jni.h>
    #include <stdio.h>
    #include "HspellNative.h"
    #include "hspell.h"
    JNIEXPORT jint JNICALL
    Java_HspellNative_hspellInit ( JNIEnv* env, jobject obj )
         struct dict_radix **dict;
         return ( (jint) (hspell_init(dict,0) ) );
    6. could be the problematic one:
    gcc -o lib/libHspellNative.so -shared -I/opt/bea/jdk142_05/include -I/opt/bea/jdk142_05/include/linux hspell.c HspellNative.c
    7. java HspellNative
    8. getting the following error:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/haim/Hspell/hspell-0.9/lib/libHspellNative.so: /opt/haim/Hspell/hspell-0.9/lib/libHspellNative.so: undefined symbol: hspell_debug
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at HspellNative.<clinit>(HspellNative.java:18)
    My problem is that I don't know how to combine my HspellNative.c to the existing hspell.c, I know I should put them together in the shared library somehow, but how ?
    Please advice.
    Thanks in advance,
    Haim.

    I know there is something wrong with the .so, the question is: what ? and how do I fix it ?
    This is the ldd ldd libHspellNative.so output:
    /etc/libcwait.so => /etc/libcwait.so (0x0060b000)
    libc.so.6 => /lib/tls/libc.so.6 (0x00111000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00359000)
    I have no idea what it means...
    I think I will try the SWIG.
    Thanks any way.

  • How to run a simple program with main?

    I have a simple class with main, something like the following:
    public static void main(String[] args) {
    Is it possible to run / execute this main from within workshop?

    In SP2 we've made it very easy to automatically set the main class name
    when you first try to run a class in a Java project that doesn't have
    already have debugging configured.
    More generalized ways to easily run a class with a main method are
    already on the list for the next release.
    Thanks for the feedback,
    Josh
    Carl wrote:
    Thanks, that worked:)
    Workshop should consider dealing with simple classes with main much
    simpler...
    "Josh Eckels" <[email protected]> wrote in message
    news:3f96f8c1$[email protected]..
    Yes, you can run and debug it, but it needs to be in a Java project. If
    it's not already in one, create a new Java project and copy in the
    source. Go to the Project Properties, and select the Debugger settings.
    Enter the class that contains the main method. If you'd like, you can
    set the checkbox for Build before Debugging so that you are always
    running off the current source code.
    You should then be able to run the project after building it.
    Josh
    Carl wrote:
    I have a simple class with main, something like the following:
    public static void main(String[] args) {
    Is it possible to run / execute this main from within workshop?

  • How to run GPIB based programs with visual basic 3

    I have a little test program to comunicate with a GPIB device in a similar way that MAX does.
    I type the address of the device, send the command *IDN?
    but nothing returns except an error message that says s$ duplicate definition. I'm not terribly familiar with VB 3.0 Does anyone know what this means and how to fix it?

    I'm assuming since you're using VB 3, I assume you're calling directly into gpib-32.dll - is that correct? Could you possibly post the VB code? Also, if it's possible for you to use a later version of VB, we have ActiveX controls for VB6 and .NET classes for VB.NET that would make GPIB-based I/O much simpler to do than it would be in VB 3.0

  • How to run at a frequency with labview under linux....

    hello i have a probleme with the "wait" VI that's seems to not works...if fact if the "wait"vi is under 2ms the program is running at a very high frequency (about 1000 hz) and over the program is running at 50 hz ...
    is there anyway to have a better control of my frequency...
    thanks
    juju

    thanks Isabelle for your reply...
    j'ai beau changé le VI pour controller le temps, mais cela n'arrange rien. je ne sais pas si en anglais je suis tres clair... en fait ... si je ne ne controlle pas le temps avec un VI style wait ou wait *ms, ou bien encore la boite de dialogue la frequence est de 250 Hz....
    et si je met un vi pour controller le temps (quel qu'il soient d'ailleurs)la frequence reste tout le temps stable a 50 Hz (malgré bien sur le fait de changer l'entrée sur le VI...).
    ce que je comprend vraiment pas se trouve resumer ici...Pourquoi n'ya t'il pas de progression possible entre ces deux frequences. est-ce par ce que le VI time consomme tellement de ressource (???)...
    j'ai lu (vaguement) sur le forum qu'on pouvait allouer une importance dans le traitement des 5 programmes que generes labview... je ne sait pas si mon probleme vient de la sachant que labview consomme peu en ressources (+- 5% ressources utilisateurs...).
    j'ai aussi tenter de modifier les parametres VI Properties--> execution... mais le probleme persiste...
    je travaille avec la version 7.0 installé a partir du CD grace aux RPM sous une mandrake 9.2...
    si quelqu'un a connu les memes deboire que moi qu'il me contacte....lol
    a+ merci
    juju

  • Using LabView to run VB program with parameters

    Hi,
    It's my first message here so I hope I am doing things correctly. I tried to do some research before asking and I found a lot of good informations but right now, I seem to be stuck.
    I am quite new to LabView, I did few VIs here and there but nothing really "serious". I am currently working on a LabView interface that deals with VB, Excel macros and Data extraction from Text file.
    The VB program is in charge of a motor position, then, some Excel macros are used to do some measurement and the results are written in a text file that I use to plot some graphs.
    The VB program I made give the window I put in the picture in the attached files. Basically, you have to enter some values in those TextBox then click on Move and the motor will move. When you click on the button Home, the motor moves back to the position "0", no need of the two TextBox. In my labview interface, I created two ComboBox that contain all the possible values for both of the TextBox of my VB program. What I would like to do, when I click on my "Measure" button on LabView that initiates the VB program, is that it can fill the two TextBox from VB with the data entered in my LabView ComboBox and then run the program, simulating a "click" on the Move button.
    Right now, I found a VI (included in the attached files) that runs my VB program from LabView (I use it as a Sub-VI) but I still have to manually put the values in my VB program. My goal would be that when I click on my LabView button to start my measure, the motor moves but the VB program doesn't show up for the user to manually enter the values he wants.
    I hope I was clear but if you need any clarification.
    I did the the VB program myself.
    I can also link the LabView interface I already created if need be.
    Thanks for your help,
    Baptiste
    Attachments:
    Moteur.png ‏5 KB
    lancerEXE.vi ‏9 KB

    First, thank you for your answers.
    I know that I don't need to use VB or LabView. I just want for myself to be able to use LabView to manage a program in VB, one in VBA and use data from a text file. I know I could write everything in VBA and that would get the job done. The thing is I want to get away from VBA and Excel as much as I can. In the future, the plan would be to re-write my VBA program with LabView but as of now, I just want to use LabView to manage everything. I know I don't really need it but I want to learn how to do it and have something that works.
    So I would like to know if there is way to do what I wish to do, running my VB program with parameters coming from LabView.
    Thanks

  • Help! Running Fortran program with Xcode

    Hi all,
    I am developing a Fortran code for a class project, I understand Matlab, but very little of advanced programming like Fortran or C++, but have to learn some for my class (note: it is not a programming class). The professor gave us a code to run and modify it, the code is supposed to work (and in fact it is working on windows computers). I didn't know how to run Fortran on a mac so I followed the instructions given in these links:
    http://www.macresearch.org/xcodegfortran_contest_winner_damienbobillot
    http://lists.apple.com/archives/fortran-dev/2006/Mar/msg00011.html
    I installed Xcode 2.4, and gfortran. After I made my Project on Xcode (following the links above), I clicked Build and it was successful, but after I clicked Build and Go I got the following error:
    Warning:Array reference at (1) is out of bounds
    Command/usr/local/bin/gfortran failed with exit code 1
    I don't know what does that mean. Can anyone help me with this?
    I would like some easy-to-follow instructions to run a Fortran program with Xcode, starting from the basics.
    It is hard to find an easy compiler for mac, PC people have qFortran (for free at at school) and things like that where you just have to click compile and that is it.
    Thanks!
    lbml

    I'd need to see your code to give details, but the error you got says you declared an array with a certain number of elements and then you tried to talk to the array outside those elements.
    For example you say:
    integer myArray(5)
    and then try to index either myArray(0) or myArray (6).
    Does that make sense. I have never tried to get fortran working with Xcode, but I did get Pascal working, so it is probably better is someone else helps you, but I will try if no one steps up.

  • Problem with JNI form C++

    Hi all,
    I'm fairly new to programming with JNI, so please excuse me if I ask a dumb question.
    I'm trying to call a Java method from a C++ class, but when I run the program, it throws an error, crashing the program. I'm pretty sure the problem is that the call to env->getMethodID() is throwing an error. I have looked around to try and find a way call a function with no arguments, but all of the examples that I have found all call a Java main.
    I'll post my code and the error message below so that things are a bit clearer.
    Thanks,
    Robert.
    Here is the main.cpp. This is where the program is started.
    #include "/usr/lib/jvm/java-6-sun-1.6.0.06/include/jni.h"
    int main()
       JNIEnv *env;
       JavaVM *jvm;
       jint res;
       jclass cls;
       jmethodID mid;
       // creation of the JVM
       JavaVMInitArgs vm_args;
       JavaVMOption options[1];
       options[0].optionString = "-Djava.class.path= .";
       vm_args.version = 0x00010002;
       vm_args.options = options;
       vm_args.nOptions = 1;
       vm_args.ignoreUnrecognized = JNI_TRUE;
       res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
       // now the rest of the code can work
       cls = env->FindClass("Test");
       mid = env->GetMethodID(cls, "run", "()V");
       env->CallVoidMethod(cls, mid);
       jvm->DestroyJavaVM();
    }Here is Test.java
    public class Test
       public void run()
          System.out.println("stuff");
          foo();
       public void foo()
          System.out.println("asdfasdf");
    }And here is the error message.
    # An unexpected error has been detected by Java Runtime Environment:
    #  SIGSEGV (0xb) at pc=0x06245f7d, pid=9054, tid=1076641792
    # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode, sharing linux-x86)
    # Problematic frame:
    # V  [libjvm.so+0x245f7d]
    # An error report file with more information is saved as:
    # /media/MY STICK/jni/cpp/hs_err_pid9054.log
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    AbortedEdited by: metaldrummer610 on Apr 23, 2008 8:35 PM

    Yeah, so I just figured out what was wrong. I wasn't calling main from in Java. My bad guys.

  • Sourcing : Error while Running Java Concurrent Program

    Hi All,
    Navigations:
    Application: Sourcing
    Responsibility : Sourcing Buyer
    Concurrent Program : Generate and Store Sourcing response spreadsheet
    I am trying to run
    Java Concurrent Program : Generate and Store Sourcing response spreadsheet in SRS Window,
    it completed with Error status.
    Please let me know How can I run this Concurrent Program with Normal status and able to view/save the Output.
    Please provide resolution on this.

    Thanks for your reply..
    Program: Generate and Store Sourcing response spreadsheet
    ShortName: PON_EXPORT_RESPONSE
    Application: Sourcing
    Executable: ExportResponseCp
    Method: Java Concurrent Program
    Responsibility : Sourcing Buyer.
    Has this ever worked? If yes, any changes been done recently?
    => No
    Is this the seeded concurrent program or a custom one?
    => Its seeded program.
    EBS: R12.1.3
    Login as Sourcing Buyer Responsibility :
    When you create RFQ and then Close RFQ and then create Surrogate quote and after you Export the Spreadsheet in SelfService Pages it generates the output.
    But if You run the concurrent program (Generate and Store Sourcing response spreadsheet) it errors out.
    Error : Exception in thread main java .lang.stringIndexOutOfBoundException:
    Thanks..

  • Java.lang.OutOfMemoryError when running java concurrent program

    Hi,
    i had written a java concurrent program to create the content items into Oracle Content Manager (OCM). Process the records from interface table and create the content items into OCM by calling the API IBC_CITEM_ADMIN_GRP.upsert_item().
    I run the concurrent program with 2000 records in interface table, it's an one to one process, 563 records are processed and 563 content items are created successfully in OCM. After 563 records continuously throws the Exception
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.put_line('EX - bundle validation others--');
    x_return_status := FND_API.G_RET_STS_ERROR;
    FND_MESSAGE.Set_Name('IBC', 'A_BUNDLE_ERROR');
    FND_MESSAGE.set_token('SITUATION', 'VALIDATION');
    FND_MSG_PUB.ADD;
    IF IBC_DEBUG_PVT.debug_enabled THEN
    IBC_DEBUG_PVT.end_process(
    IBC_DEBUG_PVT.make_parameter_list(
    p_tag => 'OUTPUT',
    p_parms => JTF_VARCHAR2_TABLE_4000(
    'x_return_status', '*** EXCEPTION *** [' || SQLERRM || ']'
    END IF;
    in IBC_CITEM_ADMIN_GRP.validate_attribute_bundle() API.
    Again running the concurrent program it process another 563 records. Can any one help me to fix this issue?
    i figured out the exception. When debug the error, i got the actual error message like this
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.OutOfMemoryError
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerException
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.ArrayIndexOutOfBoundsException: -2048 < 0
    for this issue i increased the heap memory size up to 1024MB. Still i have the same issue. Can any one help to fix the issue?

    ORA-29532: Java call terminated by uncaught Java
    exception: java.lang.NullPointerException
    ORA-29532: Java call terminated by uncaught Java
    exception: java.lang.ArrayIndexOutOfBoundsException:
    -2048 < 0Aren't the null pointer and arrayindexoutofbounds, the ones which you get when you are trying to read beyond your array? (example: when your loop tries to access the 563rd element in your array, since your array index starts from 0)?
    May be if you can try to write out your elements in the array, you might see what it is croaking about.
    Thanks,
    Chiru

Maybe you are looking for