public static void main(String[] args) throws IOException, URISyntaxException {
    // 'Greeting' comes from the dependency artfiact.
    String greeting = Greeting.getGreeting();

    // Gets the contents of the resource file 'world'.
    try (BufferedReader reader =
        new BufferedReader(
            new InputStreamReader(
                HelloWorld.class.getResourceAsStream("/world"), StandardCharsets.UTF_8))) {
      String world = reader.readLine();
      System.out.println(greeting + ", " + world + ". " + (args.length > 0 ? args[0] : ""));
      Path worldFilePath = Paths.get("/app/resources/world");
      if (worldFilePath.toFile().exists()) {
        System.out.println(Files.getLastModifiedTime(worldFilePath).toString());
      }

      // Prints the contents of the extra files.
      if (Files.exists(Paths.get("/foo"))) {
        System.out.println(
            PosixFilePermissions.toString(Files.getPosixFilePermissions(Paths.get("/foo"))));
        System.out.println(
            PosixFilePermissions.toString(Files.getPosixFilePermissions(Paths.get("/bar/cat"))));
        System.out.println(
            new String(Files.readAllBytes(Paths.get("/foo")), StandardCharsets.UTF_8));
        System.out.println(
            new String(Files.readAllBytes(Paths.get("/bar/cat")), StandardCharsets.UTF_8));
        System.out.println(Files.getLastModifiedTime(Paths.get("/foo")).toString());
        System.out.println(Files.getLastModifiedTime(Paths.get("/bar/cat")).toString());
      }
      // Prints the contents of the files in the second extra directory.
      if (Files.exists(Paths.get("/custom/target/baz"))) {
        System.out.println(
            new String(
                Files.readAllBytes(Paths.get("/custom/target/baz")), StandardCharsets.UTF_8));
        System.out.println(Files.getLastModifiedTime(Paths.get("/custom/target/baz")).toString());
      }

      // Prints jvm flags
      for (String jvmFlag : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
        System.out.println(jvmFlag);
      }

      if (System.getenv("env1") != null) {
        System.out.println(System.getenv("env1"));
      }
      if (System.getenv("env2") != null) {
        System.out.println(System.getenv("env2"));
      }

      Package pack = HelloWorld.class.getPackage();
      if (pack.getImplementationTitle() != null) {
        System.out.println("Implementation-Title: " + pack.getImplementationTitle());
        System.out.println("Implementation-Version: " + pack.getImplementationVersion());
      }
    }
  }
Example class that uses a dependency and a resource file.
jib-maven-plugin/src/test/resources/maven/projects/simple/src/main/java/com/test/HelloWorld.java