Java Intermec ITCScan 无法加载

Posted

技术标签:

【中文标题】Java Intermec ITCScan 无法加载【英文标题】:Java Intermec ITCScan failed to load 【发布时间】:2016-10-17 10:05:40 【问题描述】:

我正在尝试为 CK71 ATEX Intermec 扫描仪实现条形码阅读器。操作系统是 Windows Embedded Handheld 6.5,作为 JVM,我使用的是 phoneME Personal Profile。我确实安装了 DC_Java_WM6_Armv4i.cab(见图)

当我运行下面的代码时,出现以下错误ITCScan failed to load. java.lang.UnsatisfiedLinkError: no ITCScan.dll in java.library.path

我该如何解决这个错误? 我什么都试过了。

请注意,我之前使用的是CreME JVM,一切正常。当我的 30 天评估版到期时,我放弃了 CreME。

.lnk文件的内容(当然不是myProject.MainClass才是真名):

255#"\Program Files\pMEA PP\bin\cvm.exe" "-Xopt:stdioPrefix=\My Documents,useConsole=false" -cp "\My Documents\Trasabilitate.jar;\My Documents\DataCollection.jar" myProject.MainClass

完整代码如下:

/*
 * BarcodeSample.java
 *
 * COPYRIGHT (c) 2004 INTERMEC TECHNOLOGIES CORPORATION, ALL RIGHTS RESERVED
 */

import java.awt.*;

import com.intermec.datacollection.*;


/**
 * This sample demonstrates using the BarcodeReader class to
 * read barcode data into a text field.
 */
public class BarcodeSample extends Frame implements BarcodeReadListener

    BarcodeReader bcRdr;
    TextField txtFieldData;
    Button btnClose;
    Label  labelStatus;

    public BarcodeSample(String aTitle)
    
        super(aTitle);
        initComponents();

        try
        
            bcRdr = new BarcodeReader();
            bcRdr.addBarcodeReadListener(this);
            // Starts asynchronous barcode read
            bcRdr.threadedRead(true);
        
        catch (BarcodeReaderException e)
        
            System.out.println(e);
            labelStatus.setText(e.getMessage());
            //*****
            //* Since m_labelStatus was not initialized with text,
            //* doLayout() is required on some platforms in order
            //* to show the new label text for the first setText()
            //* call.
            //*****
            doLayout();
        
    

    private void initComponents()
    
        setLayout(new FlowLayout());
        txtFieldData = new TextField(20);
        add(txtFieldData);
        btnClose = new Button("Close");
        add(btnClose);
        labelStatus = new Label();
        add(labelStatus);

        btnClose.addActionListener(new java.awt.event.ActionListener()
        
            public void actionPerformed(java.awt.event.ActionEvent e)
            
                exitApp();
            
        );
        btnClose.addKeyListener(new java.awt.event.KeyListener() 
            public void keyPressed(java.awt.event.KeyEvent e) 
                if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER)
                
                    exitApp();
                
            
            public void keyReleased(java.awt.event.KeyEvent e) 
            public void keyTyped(java.awt.event.KeyEvent e) 
        );
    

    /**
     * This method is invoked when the BarcodeReadEvent occurs.
     */
    public void barcodeRead(BarcodeReadEvent aBarcodeReadEvent)
    
        /**
         * Uses EventQueue.invokeLater to ensure the UI update
         * executes on the AWT event dispatching thread. 
         */
        final String sNewData = aBarcodeReadEvent.strDataBuffer;
        EventQueue.invokeLater(new Runnable() 
            public void run() 
                // Displays the scanned data in the text field
                txtFieldData.setText(sNewData);             
            
        );
    

    public void exitApp()
    
        if (bcRdr != null)
            bcRdr.dispose(); // Release system resources used by BarcodeReader
        setVisible(false);
        dispose(); // Dispose the frame
        System.exit(0);
    

    public static void main(String[] args)
    
        final BarcodeSample asyncReader =
            new BarcodeSample("Barcode Sample");
        asyncReader.addWindowListener(new java.awt.event.WindowAdapter()
        
            public void windowClosing(java.awt.event.WindowEvent e)
            
                asyncReader.exitApp();
            ;
        );

        asyncReader.setVisible(true);
    

【问题讨论】:

【参考方案1】:

我终于让它工作了。我发现我的 java 路径使用的是 sn-p here(我会在下面发布,以防链接出现问题):

Properties p = System.getProperties();
Enumeration keys = p.keys();
while (keys.hasMoreElements()) 
    String key = (String)keys.nextElement();
    String value = (String)p.get(key);
    System.out.println(key + ": " + value);

然后我将 ITCScan.dll 添加到设置了 java.library.path 的文件夹中(在我的例子中,\ProgramFiles\pMEA PP\bin。

我不知道这是否是最优雅的解决方案,但它确实有效。希望有一天它会对某人有所帮助。

【讨论】:

以上是关于Java Intermec ITCScan 无法加载的主要内容,如果未能解决你的问题,请参考以下文章

Intermec PB42 打印图像

通过 LinePrinter API 将条码打印到 Intermec PB20

Intermec 打印机中的 DP 命令问题

Intermec 打印机在发送 IPL 命令后停止打印

使用 Intermec 打印语言版本 12 在字段中居中非固定宽度字体

从 ZPL(斑马编程语言)翻译成 IPL(Intermec 编程语言)