Search code examples
javaeclipsemavencoapcalifornium

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

I cloned the git repo. then ran mvn clean install in the repo folder. I now want to run the hello world demo in californium/demo-apps/cf-helloworld-server/

what is the next step?

I opened the folder cd demo-apps/cf-helloworld-server then ran

  • 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

Solution

  • 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

    Afterwards change to the app directory, e.g. "demo-apps/cd-helloworld-server". There you start the server with

    "java -jar target/cf-helloworld-server-3.7.0-SNAPSHOT.jar"

    and you get the output:

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

    Usage: Server (HelloWorldServer|MulticastTestServer)

    Follow the usage:

    "java -jar target/cf-helloworld-server-3.7.0-SNAPSHOT.jar HelloWorldServer"

    and you run the HelloWorldServer.