[Rxtx] Linux Library

Marco Mornati mmornati at byte-code.com
Fri Jan 30 02:32:44 MST 2009


Hello,

I made a little Applet added to my web application to support BarCode
printer (on serial port).
All is autoconfigured during applet init: dll/so are copied on /tmp
folder on local computer and with System.load(/tmp/library.so/dll) I'm
adding the library to classpath.

On windows all works correctly and I'm able to print (jar is signed...
without signing it there's no way to communicate with serial port).
I've just a little problem on linux. It seams that library is not added
to classpath, because when I try to connect with com port, applet says
that is impossible to find .so.

Any idea on what could be the problem?

Just for information I post here my code:

Container content = getContentPane();
        content.setBackground(Color.white);
        content.setLayout(new FlowLayout());
        String libraryFile = "";
        String libraryName = "";
        if
(System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
            libraryName = DLL_SERIAL_NAME;
            libraryFile = System.getProperty("java.io.tmpdir") +
DLL_SERIAL_NAME;
        } else if
(System.getProperty("os.name").toUpperCase().contains("LINUX")) {
            if (System.getProperty("os.arch").contains("i386")) {
                libraryName = SO_SERIAL_NAME_32;
            } else {
                libraryName = SO_SERIAL_NAME_64;
            }
            
            char fileSeparator =
System.getProperty("file.separator").charAt(0);
            libraryFile = System.getProperty("java.io.tmpdir") +
fileSeparator + SO_SERIAL_NAME;
        }

        System.out.println("Library File: " + libraryFile);
        /**
         * Copying DLL to java bin dir (if it's not already present)
         */
        if (!verifyLibraryExistence(libraryFile)) {
            System.out.println("Library file does not exist");
            copyResourceFromJar(libraryFile, libraryName);
        }
        try {
            System.load(libraryFile);
        } catch (Exception e) {
            System.out.println("Cannot load " + libraryFile + " you have
to install it manually!!");
        }

        try {
            content.add(new JLabel("Initializing Applet!"));
            Enumeration portList =
CommPortIdentifier.getPortIdentifiers();
            content.add(new JLabel("List Porte: " + portList));
            if (portList == null) {
                content.add(new JLabel("No Serial Port Found!!"));
            }
            while (portList.hasMoreElements()) {
                portId = (CommPortIdentifier) portList.nextElement();
                if ((portId.getPortType() ==
CommPortIdentifier.PORT_SERIAL)) {
                    System.out.println("Porta Trovata: " +
portId.getName());
                    content.add(new JLabel("Porta Trovata: " +
portId.getName()));
                }
                break;
            }
        } catch (Exception e) {
            content.add(new JLabel("Exception: " + e));
            e.printStackTrace();
        }


Thanks a lot
Bye
Marco
-- 
Dott. Ing. Mornati Marco
Byte-Code s.r.l
via Antonio Cechov, 1
San Giuliano Milanese (MI)
E-Mail: mmornati at byte-code.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://mailman.qbang.org/pipermail/rxtx/attachments/20090130/c176573f/attachment-0963.sig>


More information about the Rxtx mailing list