Coder Social home page Coder Social logo

Comments (4)

miha-plesko avatar miha-plesko commented on July 29, 2024 2

@pritip123 thanks for asking. Until now I've always been compiling my simple Java application with javac directly. Let me play a little with mvn, I'll let you know when it works on OSv.

BTW, if you can, it would help if you could share your maven application with us so that we can play with it directly. If this is not possible, then no problem, we will create our own small application.

from capstan-packages.

pritip123 avatar pritip123 commented on July 29, 2024 2

Thanks a lot @gasper-vrhovsek and @miha-plesko . I was not adding jvm_args as jar file and so its always looking for the main class instead of jar file .Its working fine now.

from capstan-packages.

gasper-vrhovsek avatar gasper-vrhovsek commented on July 29, 2024

@pritip123 did you perhaps package the jar with dependencies? Check if your maven build configuration looks something like this:

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifest>
              <mainClass>com.example.Main</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

from capstan-packages.

miha-plesko avatar miha-plesko commented on July 29, 2024

Hello @pritip123, we've been playing with following Java application that makes use of some external dependencies:

package org.xlab;

import org.apache.commons.io.output.StringBuilderWriter;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        StringBuilderWriter sbw = new StringBuilderWriter();

        sbw.append("Hello");
        sbw.append(" ");
        sbw.append("world");

        System.out.println(sbw.toString());
    }
}

We then used Maven to build a fat jar by using the snippet that @gasper-vrhovsek kindly provided in the comment above. The result was a target/osv_sample-1.0-SNAPSHOT-jar-with-dependencies.jar file that we've copied into a new directory with following structure:

demo/
├── meta/
│   ├── package.yaml
│   └── run.yaml
└── osv_sample-1.0-SNAPSHOT-jar-with-dependencies.jar

The content of the two meta files was as follows:

# meta/package.yaml

name: demo
title: Maven Demo
author: me
# meta/run.yaml

runtime: java
config_set: 
  hello:
    jvm_args:
      - "-jar"
    main: /osv_sample-1.0-SNAPSHOT-jar-with-dependencies.jar
    classpath:
      - /

config_set_default: hello

Then I cd into the demo/ directory and execute:

$ cd demo
$ capstan package compose demo --pull-missing
$ capstan run demo --boot hello
Command line will be set based on --boot parameter
Created instance: demo
Setting cmdline: runscript /run/hello
OSv v0.24-434-gf4d1dfb
eth0: 192.168.122.15
java.so: Starting JVM app using: io/osv/nonisolated/RunNonIsolatedJvmApp
java.so: Setting Java system classloader to NonIsolatingOsvSystemClassLoader
Hello world

Most probably you were using the incorrect parameters inside meta/run.yaml since we haven't documented how one is to run .jar files yet. I will update README on Capstan to make this clear, thanks for noticing!

from capstan-packages.

Related Issues (5)

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.