简体   繁体   English

如何使用 Maven californium 运行 helloWorld - Java

[英]How to run helloWorld using Maven californium - Java

I am new to Java environment, I'm trying to run a Coap server using Californium https://github.com/eclipse-californium/californium我是 Java 环境的新手,我正在尝试使用Californium https://github.com/eclipse-californium/californium运行Coap服务器

I cloned the git repo.我克隆了 git 存储库。 then ran mvn clean install in the repo folder.然后在 repo 文件夹中运行mvn clean install I now want to run the hello world demo in californium/demo-apps/cf-helloworld-server/我现在想在californium/demo-apps/cf-helloworld-server/中运行 hello world 演示

what is the next step?你下一步怎么做?

I opened the folder cd demo-apps/cf-helloworld-server then ran我打开文件夹cd demo-apps/cf-helloworld-server然后运行

  • mvn clean install
  • mvn compile

it worked without errors, now how to run the server?它工作没有错误,现在如何运行服务器?

if I run:如果我运行:

java target.classes.org.eclipse.californium.examples.HelloWorldServer

I get this error我收到这个错误

Error: Unable to initialize main class org.eclipse.californium.examples.Server
Caused by: java.lang.NoClassDefFoundError: org/eclipse/californium/elements/exception/ConnectorException

Please build not only a demo-app, that doesn't work from scratch.请不要只构建一个演示应用程序,它不能从头开始工作。

Instead build the parent (root folder of californium) with而是使用

mvn clean install mvn 干净安装

Afterwards change to the app directory, eg "demo-apps/cd-helloworld-server".然后切换到应用程序目录,例如“demo-apps/cd-helloworld-server”。 There you start the server with在那里你启动服务器

"java -jar target/cf-helloworld-server-3.7.0-SNAPSHOT.jar" “java -jar 目标/cf-helloworld-server-3.7.0-SNAPSHOT.jar”

and you get the output:你得到 output:

Californium (Cf) Server-Starter (c) 2020, Bosch.IO GmbH and others Californium (Cf) Server-Starter (c) 2020, Bosch.IO GmbH 等

Usage: Server (HelloWorldServer|MulticastTestServer)用法:服务器(HelloWorldServer|MulticastTestServer)

Follow the usage:遵循用法:

"java -jar target/cf-helloworld-server-3.7.0-SNAPSHOT.jar HelloWorldServer" “java -jar 目标/cf-helloworld-server-3.7.0-SNAPSHOT.jar HelloWorldServer”

and you run the HelloWorldServer.然后运行 HelloWorldServer。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM