Menu

#6 Using different filenames for Linux native library

Unstable (example)
open
nobody
None
5
2014-08-15
2014-03-03
No

Hi,

I'm the admin of DocFetcher, and I'd like to propose renaming the two native libraries of JNotify for Linux, so that there are different filenames for the 32-bit and 64-bit version, e.g. libjnotify.so vs. libjnotify_64bit.so.

The reason for this is that there are programs out there (such as DocFetcher) that run both on 32-bit and 64-bit systems, without using different program packages. Currently, because of the identical names for the Linux native library, the only way to realize this is to modify the JNotify source code.

It would nice if the required changes could be incorporated directly into JNotify. The changes are as follows: At the beginning of JNotify_linux.java, replace the static block with the following code:

static
{
    if (!isJava64())
        System.loadLibrary("jnotify");
    else
        System.loadLibrary("jnotify_64bit");

    int res = nativeInit();
    if (res != 0)
    {
        throw new RuntimeException("Error initializing fshook_inotify library. linux error code #" + res  + ", man errno for more info");
    }
    init();
}

private static boolean isJava64() {
    String arch = System.getProperty("sun.arch.data.model");
    if (arch == null)
        arch = System.getProperty("os.arch").toLowerCase();
    return arch.contains("64");
}

Best regards
q:-) <= Quang

Related

Patches: #6

Discussion

  • Nam-Quang Tran

    Nam-Quang Tran - 2014-03-03

    By the way, the above code contains a superfluous ".toLowerCase()".

     
    • Omry Yadan

      Omry Yadan - 2014-03-04

      I am traveling this week, wiki get back to you sometime next week.
      If i forget please ping again.

      On Mar 3, 2014, at 8:41 AM, "Nam-Quang Tran" qforce@users.sf.net wrote:

      By the way, the above code contains a superfluous ".toLowerCase()".

      [patches:#6] Using different filenames for Linux native library

      Status: open
      Group: Unstable (example)
      Created: Mon Mar 03, 2014 01:38 PM UTC by Nam-Quang Tran
      Last Updated: Mon Mar 03, 2014 01:38 PM UTC
      Owner: nobody

      Hi,

      I'm the admin of DocFetcher, and I'd like to propose renaming the two native libraries of JNotify for Linux, so that there are different filenames for the 32-bit and 64-bit version, e.g. libjnotify.so vs. libjnotify_64bit.so.

      The reason for this is that there are programs out there (such as DocFetcher) that run both on 32-bit and 64-bit systems, without using different program packages. Currently, because of the identical names for the Linux native library, the only way to realize this is to modify the JNotify source code.

      It would nice if the required changes could be incorporated directly into JNotify. The changes are as follows: At the beginning of JNotify_linux.java, replace the static block with the following code:

      static
      {
      if (!isJava64())
      System.loadLibrary("jnotify");
      else
      System.loadLibrary("jnotify_64bit");

      int res = nativeInit();
      if (res != 0)
      {
          throw new RuntimeException("Error initializing fshook_inotify library. linux error code #" + res  + ", man errno for more info");
      }
      init();
      

      }

      private static boolean isJava64() {
      String arch = System.getProperty("sun.arch.data.model");
      if (arch == null)
      arch = System.getProperty("os.arch").toLowerCase();
      return arch.contains("64");
      }
      Best regards
      q:-) <= Quang

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jnotify/patches/6/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Patches: #6

  • Nam-Quang Tran

    Nam-Quang Tran - 2014-03-14

    Bumping up request.

     
    • Matthew Donoughe

      Does os.arch return 64-bit when running 32-bit Java on a 64-bit kernel?
      On Mar 14, 2014 6:26 AM, "Nam-Quang Tran" qforce@users.sf.net wrote:

      Bumping up request.

      Status: open
      Group: Unstable (example)
      Created: Mon Mar 03, 2014 01:38 PM UTC by Nam-Quang Tran
      Last Updated: Mon Mar 03, 2014 01:41 PM UTC
      Owner: nobody

      Hi,

      I'm the admin of DocFetcher https://sourceforge.net/projects/docfetcher/,
      and I'd like to propose renaming the two native libraries of JNotify for
      Linux, so that there are different filenames for the 32-bit and 64-bit
      version, e.g. libjnotify.so vs. libjnotify_64bit.so.

      The reason for this is that there are programs out there (such as
      DocFetcher) that run both on 32-bit and 64-bit systems, without using
      different program packages. Currently, because of the identical names for
      the Linux native library, the only way to realize this is to modify the
      JNotify source code.

      It would nice if the required changes could be incorporated directly into
      JNotify. The changes are as follows: At the beginning of
      JNotify_linux.java, replace the static block with the following code:

      static{
      if (!isJava64())
      System.loadLibrary("jnotify");
      else
      System.loadLibrary("jnotify_64bit");

      int res = nativeInit();
      if (res != 0)
      {
          throw new RuntimeException("Error initializing fshook_inotify library. linux error code #" + res  + ", man errno for more info");
      }
      init();}
      

      private static boolean isJava64() {
      String arch = System.getProperty("sun.arch.data.model");
      if (arch == null)
      arch = System.getProperty("os.arch").toLowerCase();
      return arch.contains("64");}

      Best regards
      q:-) <= Quang


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/jnotify/patches/6/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Patches: #6

      • Nam-Quang Tran

        Nam-Quang Tran - 2014-03-14

        Does os.arch return 64-bit when running 32-bit Java on a 64-bit kernel?

        sun.arch.data.model and os.arch both return the bitness of the JRE, not of the operating system. So, in this case, it will return 32-bit. See also: This StackOverflow post.

         
  • Omry Yadan

    Omry Yadan - 2014-03-14

    I think you want to link with the 32bit binary when running on a 32bit JRE even if the OS is 64 bit.

    There is another recent patch about this (https://sourceforge.net/p/jnotify/patches/5/).
    are you working with the other author?

     
    • Nam-Quang Tran

      Nam-Quang Tran - 2014-03-14

      I think you want to link with the 32bit binary when running on a 32bit JRE even if the OS is 64 bit.

      Yes, that's what I want. If the user runs the 32-bit JRE, load 32-bit JNotify, if he/she runs 64-bit JRE, load 64-bit JNotify. With the current JNotify version, this already works for Windows and OS X.

      are you working with the other author?

      No. I didn't know about the other patch.

       
  • Matthew Donoughe

    See Util.java 1.2. I've attempted to normalize the architecture because different compatible(?) JVMs can report different values on the same architecture.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.