Java Web Start (Jnlp) Tutorial | Code Factory

package com.codeFactory;import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import javax.jnlp.BasicService;
import javax.jnlp.ServiceManager;
import javax.jnlp.UnavailableServiceException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Test {
static BasicService basicService = null;
public static void main(String args[]) {
JFrame frame = new JFrame("Code Factory");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel();
Container content = frame.getContentPane();
content.add(label, BorderLayout.CENTER);
String message = "Jnlp Hello Word";
label.setText(message);try {
basicService = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
} catch (UnavailableServiceException e) {
System.err.println("Lookup failed: " + e);
}
JButton button = new JButton("http://34codefactory.wordpress.com");ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
try {
URL url = new URL(actionEvent.getActionCommand());
basicService.showDocument(url);
} catch (MalformedURLException ignored) {
}
}
};
button.addActionListener(listener);content.add(button, BorderLayout.SOUTH);
frame.pack();
frame.show();
}
}
keytool -genkey -keystore testKeys -alias jdc
jarsigner -keystore testKeys TestJnlp.jar jdc
<?xml version="1.0" encoding="utf-8"?> 
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="Test.jnlp">
<information>
<title>Jnlp Testing</title>
<vendor>YONG MOOK KIM</vendor>
<homepage href="http://localhost:8080/" />
<description>Testing Testing</description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" />
<jar href="TestJnlp.jar" />
</resources>
<application-desc main-class="com.codeFactory.Test" />
</jnlp>

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Writing an automated Amazon S3 backup script for your MongoDB database using bash and cron in…

Why is Yoroflow the right-fit workflow automation software for your business?

Accessing Azure Key Vault from Python Functions

HTML Element

Applying a Scrum approach to Sales — A hypothesis

Check out our new client-side integration support and deploy personalized recommendations faster

Streamlabs OBS V1 is Officially Here!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Code Factory

Code Factory

More from Medium

Unique Paths II (Java Code)

Java Garbage Collector

TIL 0510 Java Lambda

Java Reflection, part 1: primitives, arrays, classes