Giter VIP home page Giter VIP logo

Comments (17)

cescoffier avatar cescoffier commented on May 20, 2024

Yes, here are the right command line:

vertx run Server.java -ha -cluster-host 192.168.1.29 -cp ../../../../../../../../target/classes/:/Users/clement/Projects/vert.x/vertx-examples/examples-utils/target/classes

and

vertx bare -cluster-host 192.168.1.29 -cp ../../../../../../../../target/classes/:/Users/clement/Projects/vert.x/vertx-examples/examples-utils/target/classes

not really convenient, will find a different way.

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

(cluster-host is required on my computer because of my fancy network configuration)

from vertx-examples.

purplefox avatar purplefox commented on May 20, 2024

I think for Java examples like this it doesn't really make sense to run them on the command line.

Running in the IDE would be much simpler, so probably just easier to update the README so it talks about running in the IDE only.

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

Ok, but I need to start a bare instance from the IDE, and then kill a processus started by the IDE.

from vertx-examples.

purplefox avatar purplefox commented on May 20, 2024

Just a thought. The main issue in running the Java examples from the command line is that they reference the ExampleRunner class...

Maybe instead of using that class we can use Launcher directly and change Launcher so it looks at vertx.cwd? Then we wouldn't have deps on other classes.

from vertx-examples.

purplefox avatar purplefox commented on May 20, 2024

We could also put the logic for cwd that resolves the cwd as I mentioned in another issue so this works seamlessly on Eclipse, NetBeans and IntelliJ?

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

It would give something like:

// Convenience method so you can run it in your IDE
  public static void main(String[] args) {
    String exampleDir = "web-examples/src/main/java/" +  Server.class.getPackage().getName().replace(".", "/");

    try {
      // We need to use the canonical file. Without the file name is .
      File current = new File(".").getCanonicalFile();
      if (exampleDir.startsWith(current.getName())  && ! exampleDir.equals(current.getName())) {
        exampleDir = exampleDir.substring(current.getName().length() + 1);
      }
    } catch (IOException e) {
      // Ignore it.
    }

    Launcher.main(new String[] {
        "run",
        Server.class.getName(),
        "-Dvertx.cwd=" + exampleDir
    });
  }

WDYT ?

from vertx-examples.

purplefox avatar purplefox commented on May 20, 2024

Yes, like that, but I was thinking we should put the adjustment (i.e. the code inside the try..catch block) inside Launcher. Also you wouldn't need the "web-examples/src/main/java" part.

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

We can do it in Launcher or in a "run-example" command. It would give something like:

Launcher.main(new String[] {
        "run-example",
        Server.class.getName()
    });

It can traverse the file system to find the associated Server.java file and set the vertx.cwd system property.

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

I've fixed the HA example, using the Launcher. I've provided the instructions for the IDE and command line.

from vertx-examples.

purplefox avatar purplefox commented on May 20, 2024

Perfect

from vertx-examples.

purplefox avatar purplefox commented on May 20, 2024

I notice the other examples are still using the ExampleRunner (as reported on a user report in the google group today)

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

Yes, the ExampleRunner is still used. The "intelligent cwd detection" has been implemented here.

from vertx-examples.

purplefox avatar purplefox commented on May 20, 2024

Ah ok. I thought we were going to implement in Launcher (as mentioned in your example above)?

Then the example only has dependencies on core code and is much easier to run without having to depend on ExampleRunner....

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

Yes, but it was too close to the 3.1 deadline to implement this in the launcher. It will be in 3.2 (it's on my todo list).

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

It's not the same issue. This one was about running HA which has been fixed. Replacing the ExampleRunner should be another issue (I'm going to create one for this)

from vertx-examples.

cescoffier avatar cescoffier commented on May 20, 2024

Closing this one as the replacement of the ExampleRunner is covered by #97

from vertx-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.