# `Portals.Java`
[🔗](https://github.com/Ziinc/portals/blob/v0.1.0/packages/portals_java/lib/portals/java.ex#L1)

Run Java workers under Portals.

This package bundles the dependency-free Java worker SDK as a prebuilt
`portals.jar` (compiled for Java 17) and puts it on the worker's
classpath ahead of your own classes — nothing is fetched from Maven.

Compile your handlers against the same jar
(`javac -cp "$(mix portals.sdk_path java)" ...`), then:

    children = [
      {Portals.Pool,
       Portals.Java.worker_opts(
         main: "com.example.RunWorker",
         classpath: [Application.app_dir(:my_app, "priv/java/classes")],
         name: MyApp.Java,
         size: 2
       )}
    ]

See the [Java guide](java.html) for a full walkthrough.

# `sdk_path`

Absolute path to the bundled `portals.jar`.

# `worker_opts`

Build `Portals.start_worker/1` / `Portals.start_pool/1` options for a Java
worker.

## Options

  * `:main` (required) — the fully qualified class whose `main` runs
    `new Worker()...run(args)`.
  * `:classpath` — your own classpath entries (directories or jars),
    appended after `portals.jar`. Defaults to `[]`.
  * `:java` — the `java` launcher, as a name looked up on `PATH` or a
    path. Defaults to `"java"`.
  * `:java_args` — JVM flags placed before `-cp`, e.g. `["-Xmx512m"]`.
  * `:args` — arguments passed to `main`. Portals appends the socket path
    after these, as the last argument.
  * `:env` — extra `{name, value}` environment entries; these win over
    the ones set here.

Every other option is passed through unchanged.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
