Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#69 java swig:



If I compile the java swig library with the following command:

I get a file named instead of!

Also there is no way to install it and to have a jar file with the generated java file.
It would be cool to have the .so file in the jar also, I think this can be done…


  • Hi Kaouete, thanks for reporting this. What OS, CMake, and Swig versions are you using? If you look in example/swig/CMakeLists.txt, in the area within IF(CREATE_JAVA)... ENDIF(CREATE_JAVA) you'll see there is a little bit of logic that tries to pick a target name with or without the "lib" prefix depending on the platform. This logic will need to be extended, I guess, for your situation.
    Noone has added an install target for the java wrappers yet. You can see examples of INSTALL lines in the CMakeLists.txt for other languages, in case it inspires you to figure out a patch :-).

  • kaouete


    I am using 2.8.0, Swig 1.3.40 on Archlinux.

    At least for the version I have, I noticed that:
    In the source of the cmake swig module, there is this comment:
    # In java you want:
    # System.loadLibrary("LIBRARY");
    # then JNI will look for a library whose name is platform dependent, namely
    # MacOS : libLIBRARY.jnilib
    # Windows: LIBRARY.dll
    # Linux :

    It looks like to me that swig handles the naming, so maybe you should let it do it and just use jyarp as module name.
    (and anyway, cmake does add .jnilib at the end of the module name when necessary).

  • kaouete

    So here is a proposition for installing jyarp:

    1) Choose better package names for the generated files AND the examples (for example it.liralab.eris.yarp or maybe with robotcub somewhere in the name) to avoid conflicts.
    2) package everything in a jar file without a main class (or you can make one jar only with the yarp common classes, and one per examples. To run them one will need to add the yarp one to the classpath).
    3) for the library thing, take a look at this that explains how to exploit it, to me it looks like a not too bad solution…

    For the point 3, it is not really your problem, maybe you can just provide the jar without the library since it will be complex to make it work for every platform, it is more the problem of the user of yarp…

    I hope it helps, I don't have a the time to do it myself but I can do tests if you need me to :)
    Anyway, thanks for your help on this!

  • For the .so naming issue (, as of cmake 2.6-4 and swig 1.3.39, the code as is generates I would guess that the SWIG helper methods in cmake 2.8, which you are using, have been improved to insert a lib on UNIX style systems. If that is the case, we need to put in a conditional (we need to support cmake back to at least 2.4). It will take a little work to figure out the right conditional.
    Thanks for your suggestions for better Java packaging, and offer of testing. I'll advertise the suggestions on our mailing list and see if any of the Java users has time for it.

  • kaouete

    I think there is no version between 2.6.4 and 2.8, so for this it is easy :)
    I tried with swig 1.3.39 and the problem was also present, so I guess we only need to check for the cmake version!

  • Klaus

    By the way, is there a combination of versions for swig, cmake. yarp, etc that should surely work? A combination that has worked before for instance?
    tnx :D

  • Klaus

    There are new instructions at the site:
    It solved my problem here. ;)

    • status: open --> closed-fixed