Ubuntu java web start

Running Java Web Start (JNLP) Application Locally On Linux With OpenJDK / IcedTea

Java Web Start (JWS) technology enables a developer to deploy Java applications through Internet/Web. It uses Java Network Launch Protocol (JNLP). The facility of launching through a web page was earlier possible only to Java applets; but that approach requires the web browser to have Java Plug-in, a feature that is becoming unpopular among browser developers from the last 4-5 years; and today almost all major browsers have stopped supporting Java plug-ins. The alternative is to use JWS technology which is available as integral part of JRE since version 1.4 and allows you to embed your application (and applet as well) in a web page, so that your client can easily download the application through a browser and use it without any special installer (other than JRE).

Before deploying it on your web server, however, you would like to run and test the JWS application on your local development host, directly from the file system. This tutorial explains the steps for such local development and testing, using a minimalist example. The steps are listed below-

Читайте также:  Manager includes config inc php

Let us now see these steps in detail to better understand the procedure.

1. Write the source code of your Java application

Using your favorite editor (I use vim text editor), create the source file/s of your application. As this post is about JNLP and not about algorithms or programming, I have chosen here minimalist (do-nothing window) GUI application as example. I named my file as ‘Swinger.java’ and it contains the following code.

package test_jnlp; import javax.swing.*; public class Swinger < public static void main(String args[ ]) < JFrame fr1 = new JFrame("Swing with KITE"); fr1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fr1.setSize(300, 250); fr1.setVisible(true); >> 

2. Compile your program

Compile the program as usual. I issued the following command to compile it.

This resulted in the creation of the package folder with name ‘test_jnlp‘. The package folder would contain the compiled ‘.class‘ files; in the present case, only one file with name Swinger.class was in that folder.

In the normal course of actions, one would run the application at this point, by issuing the command like:

and test whether the application program is working as desired. If it is not, then one would rectify it by looping through the previous two steps. In the present case, however, this is very very small program and being used many times in my past, I did not have to test it.

3. Compress the class files into a ‘jar‘ file

For the deployment purpose we have to put all the resources of the application into a single jar file. Here, the resources comprise the package folder and the file under it. We compress it by giving the following command.

 $ jar cf Swinger.jar test_jnlp 

This results in a file with name ‘Swinger.jar‘. In the above line, the word jar is the command to deal with the compression process. The switch ‘c’ among the letters of the word ‘cf’ tells the ‘jar’ command that it has to create a jar file; and the switch ‘f’ tells that the next entry (Swinger.jar) on the command line is the name of the file to be created. The last entry (test_jnlp) on the command line is the name of the folder which, along with its contents, is to be compressed.

4. Generate a secret key for signing the jar

Unsigned jars can not be deployed using the JNLP method; we must put our signature on it. This signature can be generated using the ‘keytool‘ utility provided in the JDK. Issue the command in the following format.

 $ keytool -genkey -keystore kite_key -alias testjws_key Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: What is the name of your organizational unit? [Unknown]: What is the name of your organization? [Unknown]: What is the name of your City or Locality? [Unknown]: What is the name of your State or Province? [Unknown]: What is the two-letter country code for this unit? [Unknown]: Is CN= --, OU= -- O= --, L= --, ST= --, C= -- correct? [no]: yes Enter key password for (RETURN if same as keystore password): 

In the above command, ‘kite_key’ is the name for the keystore (ultimately a file) and ‘testjws_key’ is the alias for the signing key. These names were chosen by me; you may choose names of your liking. Also, answer all the questions with values appropriate to your own case. I have blanked out my responses in the above interaction.

5. Sign your ‘jar’ file with the generated key

The jar file can be signed with the ‘jarsigner’ utility provided by the JDK. Issue the command in the following format.

 $ jarsigner -keystore kite_key Swinger.jar testjws_key Enter Passphrase for keystore: Warning: The signer certificate will expire within six months. 

Here, ‘kite_key’ and ‘testjws_key’ are the key and its alias name as decided in the previous step. Input the password for keystore which you have chosen in the previous step. This step will modify the jar file (in the present case, Swinger.jar) by putting the signature details into it.

6. Create ‘jnlp‘ specification file

We are now ready to create the Java Network Launch Protocol specifications file. This would be a text file and you can use your favorite text editor to create it. I used gedit editor and created a file with name swing_application.jnlp and having the following contents.

Screenshot-swing_application_jnlp_file

The ‘codebase’ attribute in the second line specifies the path of the folder where our ‘.jnlp’ and ‘.jar’ files are stored. (The value of this attribute would change when you finally deploy your application on your web server, after testing it according to this tutorial). The ‘href’ attribute there, tells to JWS, the name of our ‘.jnlp‘ file. In the ‘resources’ section, in the ‘href’ attribute of the ‘jar’ tag, you must mention the name of the signed ‘.jar‘ file in which you have stored your application. In the ‘version’ attribute of the ‘j2se’ tag, you can mention the version of JRE that is appropriate to run this application. Also, specify the starting point of your program, by setting the name of the class that encapsulates the ‘main()‘ method as the value of the ‘main-class’ attribute of the ‘application-desc’ tag.

7. Run your program as JWS application

For running your program as java Web Start application, issue the following command.

$ javaws swing_application.jnlp 

You will first see the Java web start splash screen and then the following warning message.

javaws-warning

Ignore the warning and click the ‘Run’ button. This would start your application. In the present case, the following (do-nothing, blank) window would appear.

Swing-KITE-Screenshot

Once tested locally, you may deploy the application on to your web site. For that, change the value of the ‘codebase’ attribute mentioned in Step 6 above, to the URL of your web site, where you will be hosting your application (i.e. the jar and jnlp files).

Источник

📟 Как выполнить / открыть файлы JNLP в Linux – Ubuntu / Debian / Fedora / Arch Linux

Java Network Launch Protocol (JNLP) – это протокол, который позволяет запускать приложение на клиентском рабочем столе с помощью ресурсов, размещенных на удаленном веб-сервере.

Плагин Java и программное обеспечение Java Web Start считаются клиентами JNLP, поскольку они могут запускать удаленно размещенные апплеты и приложения на клиентском рабочем столе.

Cтандартный способ доступа к Серверу iLO / IPMI – через файл JNLP, загруженный с консоли сервера.

Мне пришлось найти инструмент, который позволит мне запустить этот файл на моем рабочем столе Linux.

В этом руководстве мы установим IcedTea-Web, которая является бесплатной программной реализацией Java Web Start и плагина для веб-браузера Java.

Установка на Ubuntu / Debian

sudo apt -y install icedtea-netx icedtea-plugin

Установка на Fedora / CentOS

---- CentOS ---- sudo yum -y install icedtea-web --- Fedora ---- sudo dnf -y install icedtea-web

Установка на Arch / Manjaro

Выполнить файл JNLP в Linux

После установки вы можете выполнить файл JNLP с помощью командной строки:

Альтернативный способ выполнения файла JNLP двойным щелчком мыши.

Источник

How To Run Java Web Start Applications on Ubuntu with Firefox

Ubuntu 15

In this article, we will guide you through the process of running Java Web Start applications on Ubuntu using Firefox. This process involves installing the necessary Java plugins, configuring Firefox to use these plugins, and finally, running the Java Web Start application.

To run Java Web Start applications on Ubuntu with Firefox, you need to install the IcedTea plugin, set the default Java version to Java 7, configure Firefox to use the Java plugin, and then simply double-click on the JNLP file to run the application.

Prerequisites

  • A Ubuntu 12.10 or later system
  • Firefox browser installed
  • Terminal access with sudo privileges

Step 1: Installing the IcedTea Plugin

To run Java Web Start applications, we first need to install a compatible plugin. One such plugin is the IcedTea-Web, an open-source implementation of Java Web Start.

Open your terminal and run the following command:

sudo apt-get install icedtea-netx

In this command, sudo allows you to run commands with administrative privileges, apt-get is the package handling utility in Ubuntu, and install is used to install a package. icedtea-netx is the package we are installing, which includes the Java plugin necessary for running Java Web Start applications.

Step 2: Setting the Default Java Version

If you have multiple versions of Java installed on your system, it’s important to set the default version to Java 7. You can do this by running the following command:

sudo update-alternatives --config java

This command lists all the installed Java versions on your system. Select the Java 7 version from the list and press Enter.

Step 3: Configuring Firefox to Use the Java Plugin

Next, we need to configure Firefox to use the newly installed Java plugin. Follow these steps:

  1. Open Firefox and navigate to Preferences .
  2. In the Preferences window, click on the Applications tab.
  3. Scroll down and find the JNLP file entry.
  4. Click on the drop-down menu next to it and select Use other .
  5. In the file browser, navigate to your Java 7 installation directory, go to the bin folder, and select the javaws executable.

This process associates the JNLP file type with the Java Web Start application.

Step 4: Running the Java Web Start Application

Now that everything is set up, you can run the Java Web Start application. Simply double-click on the JNLP file you want to run. Firefox should now open the file using the Java Web Start application, and the application should start running.

Troubleshooting

If you encounter any issues, make sure you have the correct Java version installed and that the JNLP file is not corrupted. You can also try reinstalling the Java plugin and restarting Firefox.

Conclusion

Running Java Web Start applications on Ubuntu using Firefox may seem complex, but by following these steps, you can easily set up your system to run these applications. Always remember to keep your system and applications updated to ensure compatibility and security.

Yes, you can run Java Web Start applications on Ubuntu by following the steps mentioned in this article.

Java Web Start is a technology that allows users to launch Java applications directly from a web browser without the need for manual installation or updates.

The IcedTea plugin is necessary for running Java Web Start applications as it provides the required Java functionality within the Firefox browser.

To set the default Java version, you can use the sudo update-alternatives —config java command and select the desired Java version from the list.

You can configure Firefox to use the Java plugin by navigating to Preferences > Applications, finding the JNLP file entry, selecting «Use other,» and choosing the javaws executable from your Java 7 installation directory.

To run a Java Web Start application, simply double-click on the JNLP file associated with the application. Firefox will open the file using the Java Web Start application, and the application will start running.

If you encounter issues, make sure you have the correct Java version installed and that the JNLP file is not corrupted. You can also try reinstalling the Java plugin and restarting Firefox.

Источник

Оцените статью