mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
25 lines
1000 B
HTML
25 lines
1000 B
HTML
|
|
<div class="tab-wrap">
|
|
|
|
|
|
<input type="radio" id="connect_creds_java" name="connect_creds" class="tab" checked>
|
|
|
|
<label for="connect_creds_java" class="api-lang" data-language="java">Java</label>
|
|
|
|
|
|
|
|
<div class="tab__content">
|
|
<pre id="connect_creds_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectCreds.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
|
server("nats://localhost:4222").
|
|
authHandler(Nats.credentials("path_to_creds_file")).
|
|
build();
|
|
Connection nc = Nats.connect(options);
|
|
|
|
// Do something with the connection
|
|
|
|
nc.close();
|
|
</code></pre>
|
|
</div>
|
|
|
|
</div>
|