Linux上的Java(Raspbian) - 缺少依赖项?

时间:2017-06-29 13:24:30

标签: java linux plc

我是用Java开发的,但我相信除了编写有关构建,依赖项,项目,清单,类路径等的编码之外,我还缺少一些基本知识。

我将开发一个Java工具,它将从PLC读取和设置值。我发现了moka7。文档说:

Moka7 is deployed as a set of source code classes that you can use in your Java project to communicate with S7 PLCs.

我首先下载了moka7并将Eclispe项目导入我的IntelliJ IDEA(Windows 10)。我能够构建并运行ClientDemo程序。现在我想在linux上做同样的事情。当我提取moka7并尝试运行二进制文件时,我得到了:

java ClientDemo
Error: Could not find or load main class ClientDemo

当我尝试自己编译源代码时,我得到以下内容:

/opt/moka7-full-1.0.2/Moka7-Eclipse/src/Moka7Demo# javac ClientDemo.java
ClientDemo.java:28: error: package Moka7 does not exist
import Moka7.*;
^
ClientDemo.java:41: error: cannot find symbol
    private static final S7Client Client = new S7Client();
                         ^
  symbol:   class S7Client
  location: class ClientDemo
ClientDemo.java:41: error: cannot find symbol
    private static final S7Client Client = new S7Client();
                                               ^
  symbol:   class S7Client
  location: class ClientDemo
ClientDemo.java:49: error: cannot find symbol
    private static int CurrentStatus = S7.S7CpuStatusUnknown;
                                       ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:72: error: cannot find symbol
                System.out.println(S7.GetPrintableStringAt(Buffer, i-15, 16));
                                   ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:83: error: cannot find symbol
            System.out.println(S7.GetPrintableStringAt(Buffer, Size-r, r));
                               ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:112: error: cannot find symbol
        System.out.println(S7Client.ErrorText(Code));
                           ^
  symbol:   variable S7Client
  location: class ClientDemo
ClientDemo.java:117: error: cannot find symbol
        S7BlockInfo Block = new S7BlockInfo();
        ^
  symbol:   class S7BlockInfo
  location: class ClientDemo
ClientDemo.java:117: error: cannot find symbol
        S7BlockInfo Block = new S7BlockInfo();
                                ^
  symbol:   class S7BlockInfo
  location: class ClientDemo
ClientDemo.java:144: error: cannot find symbol
        IntByRef SizeRead = new IntByRef(0);
        ^
  symbol:   class IntByRef
  location: class ClientDemo
ClientDemo.java:144: error: cannot find symbol
        IntByRef SizeRead = new IntByRef(0);
                                ^
  symbol:   class IntByRef
  location: class ClientDemo
ClientDemo.java:161: error: cannot find symbol
        int Result = Client.ReadArea(S7.S7AreaDB, DBSample, 0, DataToMove, Buffer);
                                     ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:172: error: cannot find symbol
        int Result = Client.WriteArea(S7.S7AreaDB, DBSample, 0, DataToMove, Buffer);
                                      ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:204: error: cannot find symbol
        IntByRef PlcStatus = new IntByRef(S7.S7CpuStatusUnknown);
        ^
  symbol:   class IntByRef
  location: class ClientDemo
ClientDemo.java:204: error: cannot find symbol
        IntByRef PlcStatus = new IntByRef(S7.S7CpuStatusUnknown);
                                 ^
  symbol:   class IntByRef
  location: class ClientDemo
ClientDemo.java:204: error: cannot find symbol
        IntByRef PlcStatus = new IntByRef(S7.S7CpuStatusUnknown);
                                          ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:210: error: illegal start of type
            switch (PlcStatus.Value)
                   ^
ClientDemo.java:212: error: cannot find symbol
                case S7.S7CpuStatusRun :
                     ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:215: error: cannot find symbol
                case S7.S7CpuStatusStop :
                     ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:248: error: cannot find symbol
                case S7.S7CpuStatusRun :
                     ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:253: error: cannot find symbol
                case S7.S7CpuStatusStop :
                     ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:264: error: cannot find symbol
        S7OrderCode OrderCode = new S7OrderCode();
        ^
  symbol:   class S7OrderCode
  location: class ClientDemo
ClientDemo.java:264: error: cannot find symbol
        S7OrderCode OrderCode = new S7OrderCode();
                                    ^
  symbol:   class S7OrderCode
  location: class ClientDemo
ClientDemo.java:274: error: cannot find symbol
        S7CpuInfo CpuInfo = new S7CpuInfo();
        ^
  symbol:   class S7CpuInfo
  location: class ClientDemo
ClientDemo.java:274: error: cannot find symbol
        S7CpuInfo CpuInfo = new S7CpuInfo();
                                ^
  symbol:   class S7CpuInfo
  location: class ClientDemo
ClientDemo.java:287: error: cannot find symbol
        S7CpInfo CpInfo = new S7CpInfo();
        ^
  symbol:   class S7CpInfo
  location: class ClientDemo
ClientDemo.java:287: error: cannot find symbol
        S7CpInfo CpInfo = new S7CpInfo();
                              ^
  symbol:   class S7CpInfo
  location: class ClientDemo
ClientDemo.java:318: error: cannot find symbol
        S7Szl SZL = new S7Szl(1024);
        ^
  symbol:   class S7Szl
  location: class ClientDemo
ClientDemo.java:318: error: cannot find symbol
        S7Szl SZL = new S7Szl(1024);
                        ^
  symbol:   class S7Szl
  location: class ClientDemo
ClientDemo.java:333: error: cannot find symbol
        S7Protection Protection = new S7Protection();
        ^
  symbol:   class S7Protection
  location: class ClientDemo
ClientDemo.java:333: error: cannot find symbol
        S7Protection Protection = new S7Protection();
                                      ^
  symbol:   class S7Protection
  location: class ClientDemo
ClientDemo.java:360: error: cannot find symbol
        Client.SetConnectionType(S7.OP);
                                 ^
  symbol:   variable S7
  location: class ClientDemo
ClientDemo.java:383: error: cannot find symbol
        BlockInfo(S7.Block_SFC,1); // Get SFC 1 info (always present in a CPU)
                  ^
  symbol:   variable S7
  location: class ClientDemo
33 errors

当我使用引用this博客的this节点创建jar文件时,我可以运行jar:

root@rpi:/opt# java -jar Moka7-Eclipse.jar
Usage
  client <IP> [Rack=0 Slot=2]
Example
  client 192.168.1.101 0 2
or
  client 192.168.1.101
root@rpi:/opt#

我做错了什么? 如何在Linux上用Java正确编码?
或者我只是在任何IDEA的Windows上编码并使用jar方式在linux上运行?

0 个答案:

没有答案