PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Generating a standard Java archive
  • Generating a Java applet
  • To create a Java applet:
  • Current directory of a Java applet
  • Passing values between an applet and an HTML page (generated by WEBDEV or not)
  • Generating an application for Java Web Start
  • To generate an application for Java Web Start:
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
When your Java application is developed, you can:When your Java application is developed, you can create a Java archive that can be run directly. In this case, three solutions are available:
To create a Java archive, select "Workshop .. Java .. Generate Java archive".To start creating a Java archive:
  • Display the Java project configuration in the editor.
  • On the "Project" pane, in the "Generation" group, click "Generate".
Note: If the current configuration does not correspond to the Java configuration, you have the ability to use the generation button among the quick access buttons:
Note: To compile (in Java) a Java project developed in WINDEV, the J2SDK of Oracle (version 1.5 or later, checked with the versions found between version 1.5 and version 7) must be installed on the development computer. This program can be downloaded from the Oracle site.Note: To compile (in Java) a Java project developed with WINDEV, the Oracle J2SDK (version 1.6 or later, checked with the versions found between version 1.6 and version 9) must be installed on the development computer. This program can be downloaded from the Oracle site.
Generating a standard Java archive
A standard Java archive allows you to start the application by double-clicking the generated .jar file. A .bat file is also generated if the double click does not operate.
To create the Java archive:
  1. Select "Workshop .. Java .. Generate the Java archive". The wizard for creating a Java archive starts.Start the wizard for creating the Java archive:
    • Display the Java project configuration in the editor.
    • On the "Project" pane, in the "Generation" group, click "Generate".
  2. Select "Generate a Java application that can be run directly". Go to the next step and select "Generate a standard Java application". Go to the next step.Select "Generate a standard Java application". Go to the next step.
  3. Enter the name of the archive and the information found in the manifest (Company, Description and Copyright). Go to the next step.
  4. Specify the version number of Java executable. Two formats are available for the version numbers:
    • Standard format. This format is the standard format managed by Windows. This format corresponds to a set of 4 numbers separated by dots.
      • The first group of 4 digits corresponds to the number of major changes performed in the application.
      • The second group of 4 digits corresponds to the number of minor changes performed in the application.
      • The third group of 4 digits corresponds to the generation number.
        We advise you to automatically increment this number at each generation. This increment operation is automatically performed if "Automatically increment the version at each generation" is checked.
      • The last group of 4 digits corresponds to the number of reviews (branches in the SCM for example).
        We advise you to automatically increment this number at each generation. This increment operation is automatically performed if "Automatically increment the version at each generation" is checked.
    • Format for compatibility. This format was used until version 12 by default.
      Note: All the characters (digits and letters) are allowed. For example: "1.01A".
      If the option "Automatically increment the version at each generation" is checked:
      • the version number "1.01A" will become "1.01B".
      • the version number "A14Z" will become "A15A".
  5. Specify whether the WINDEV framework for Java must be included in the .jar archive. Go to the next step.
  6. Specify the other files that must be included in the ".jar" archive. You can select the JDBC drivers used to access a database for example. Go to the next step.
  7. Specify:
    • the command of the Java compiler to use. To customize this parameter (if several compilers are installed on the computer for example), select "Custom". In this screen, you can also specify the command line that will be used (see the documentation about the compiler for more details).
    • the command for creating the archive. The "Custom" option allows you to define the tool that will be used to create the archive. You can also specify the command line that will be used (see the documentation of the compiler for more details) and the content of archive manifest.
    • the command for including other archives. The "Custom" option allows you to define the tool that will be used to extract the archive as well as its command line.
  8. The ".jar" archive is created.
The corresponding file was created in the "EXE" directory of project. The execution of Java archive is started by using the jvm of jdk used for the compilation.
You will also find a ".BAT" file in the "EXE" directory of your project. This file contains the command line required to start the application and it can be run in a Windows environment.
The corresponding file was created in a sub-directory corresponding to the Java project configuration (sub-directory of EXE directory of project). The execution of Java archive is started by using the jvm of jdk used for the compilation.
You will also find a ".BAT" file in the generation directory of the Java archive. This file contains the command line required to start the application and it can be run in a Windows environment.
Note: several jvm can be installed on the same computer (32-bit and 64-bit JVM for instance) while the explorer associates the .jar files with another jvm. In this case, running the archive by double-clicking the .jar file may present some differences.
For the other environments, you must create a file used to start the ".jar" file.
For Linux, you can create a ".sh" file containing the following command line:
"java -jar MyProject.jar"
"MyProject.jar" corresponds to the ".jar" archive generated from your project.
Note: See Java and database for more details.
Generating a Java applet
Generating a Java applet allows you to display the first window of your project in an HTML page.
To start the application, double-click the HTML file generated with the Java applet.

To create a Java applet:

  1. Select "Workshop .. Java .. Generate the Java archive". The wizard for creating a Java archive starts.Start the wizard for creating the Java archive:
    • Display the Java project configuration in the editor.
    • On the "Project" pane, in the "Generation" group, click "Generate".
  2. Select "Generate a Java application that can be run directly". Go to the next step. Select "Generate a Java applet". Go to the next step. Select "Generate a Java applet". Go to the next step.
  3. Enter the name of the archive and the information found in the manifest (Company, Description and Copyright). Go to the next step.
  4. Specify the version number of Java executable. Two formats are available for the version numbers:
    • Standard format. This format is the standard format managed by Windows. This format corresponds to a set of 4 numbers separated by dots.
      • The first group of 4 digits corresponds to the number of major changes performed in the application.
      • The second group of 4 digits corresponds to the number of minor changes performed in the application.
      • The third group of 4 digits corresponds to the number of changes without GUI modification performed in the application.
      • The last group of 4 digits corresponds to the number of reviews. We advise you to automatically increment this number at each generation. This increment operation is automatically performed if "Automatically increment the version at each generation" is checked.
    • Format for compatibility. This format was used until version 12 by default.
      Note: All the characters (digits and letters) are allowed. For example: "1.01A".
      If the option "Automatically increment the version at each generation" is checked:
      • the version number "1.01A" will become "1.01B".
      • the version number "A14Z" will become "A15A".
  5. Specify the other files that must be included in the ".jar" archive. You can select the JDBC drivers used to access a database for example. Go to the next step.
  6. Define the signature parameters of the Java archive. These parameters are used to sign the Java applet in order for the user to easily identify the provider. The following parameters are required:
    • File of keys.
    • Associated password.
    • Name of key in the file.
    • Password of key.
  7. Specify:
    • the command of the Java compiler to use. To customize this parameter (if several compilers are installed on the computer for example), select "Custom". In this screen, you can also specify the command line that will be used (see the documentation about the compiler for more details).
    • the command for creating the archive. The "Custom" option allows you to define the tool that will be used to create the archive. You can also specify the command line that will be used (see the documentation of the compiler for more details) and the content of archive manifest.
    • the command for including other archives. The "Custom" option allows you to define the tool that will be used to extract the archive as well as its command line.
    • the command for generating the archive file. The "Custom" option allows you to define the tools that will be used to generate the file of keys.
    • the command for signing the archive. The "Custom" option allows you to define the tool that will be used to sign the archive as well as its command line.
  8. The creation of the Java applet is completed.
The corresponding file was created in the "EXE" directory of project. To run the test of this applet, start the HTML page for test.The corresponding file was created in a sub-directory corresponding to the Java project configuration (sub-directory of EXE directory of project). To run the test of this applet, start the HTML page for test.

Current directory of a Java applet

The current directory of an applet is the desktop by default.
Therefore, we advise you to specify the current directory with fCurrentDir when running Java applets.
WINDEV

Passing values between an applet and an HTML page (generated by WEBDEV or not)

To communicate between the applet and the host page, you can read or modify the value of the global variables of WINDEV project for the call.
To do so, you must:
  1. Declare one or more global variables in the initialization code of WINDEV project that will be used to generate the applet.
  2. In the page that is hosting the applet, enter the Javascript code used to handle the applet ("OnLoad" code of the page). Three solutions are available:
    • document.applets[<Subscript of applet in the page>]: For example, document.applets[0] to access the first applet found in the page.
    • document.applets[<Applet Name>]: For example, document.applets["MyApplet"]
      Note: If the applet was included in a page of a WEBDEV site, the applet name corresponds to the alias of applet control.
  • document.applets.<Applet name>: For example, document.applets.MyApplet
    Note: If the applet was included in a page of a WEBDEV site, the Javascript code can be typed in a Javascript browser code (browser code with a blue bar).
To read the value of a global variable of the applet, use the following Javascript code:
get<Name of global variable>()
For example:
var sValue = document.applets["MyApplet"].getMyGlobalVariable()
Caution: the name of the method is case sensitive.
To modify the value of a global variable of the applet, use the following Javascript code:
set<Name of global variable>(<Value>)
For example:
document.applets["MyApplet"].setMyGlobalVariable("Test Value")
Caution: the name of the method is case sensitive.
Important notes:
  • The global variables used for communicating between the applet and the HTML page must be simple variables (string, integer, real, boolean, ...).
  • The applet is reloaded and its global variables are reinitialized whenever the page is refreshed. Therefore, if you want to modify the value of a global variable of the applet when a click is performed on a page button, this button must not be a submit button (a submit button automatically refreshes the page once its click code has been run).
  • See Java and database for more details.
Generating an application for Java Web Start
The Java application is deployed on a Web server and it is started from a browser on the client computers. However, it is run like any standard application.
When the application is updated on the Web server, it is also updated on the client computers.
This generation option simplifies the deployment and the update of a Java application.

To generate an application for Java Web Start:

  1. Select "Workshop .. Java .. Generate the Java archive". The wizard for creating a Java archive starts.Start the wizard for creating the Java archive:
    • Display the Java project configuration in the editor.
    • On the "Project" pane, in the "Generation" group, click "Generate".
  2. Select "Generate a Java application that can be run directly". Go to the next step. Select "Generate an application for Java Web Start". Go to the next step.Select "Generate an application for Java Web Start". Go to the next step.
  3. Enter the name of the archive and the information found in the manifest (Company, Description and Copyright). Go to the next step.
  4. Specify the version number of Java executable. Two formats are available for the version numbers:
    • Standard format. This format is the standard format managed by Windows. This format corresponds to a set of 4 numbers separated by dots.
      • The first group of 4 digits corresponds to the number of major changes performed in the application.
      • The second group of 4 digits corresponds to the number of minor changes performed in the application.
      • The third group of 4 digits corresponds to the generation number.
        We advise you to automatically increment this number at each generation. This increment operation is automatically performed if "Automatically increment the version at each generation" is checked.
      • The last group of 4 digits corresponds to the number of reviews (branches in the SCM for example).
        We advise you to automatically increment this number at each generation. This increment operation is automatically performed if "Automatically increment the version at each generation" is checked.
    • Format for compatibility. This format was used until version 12 by default.
      Note: All the characters (digits and letters) are allowed. For example: "1.01A".
      If the option "Automatically increment the version at each generation" is checked:
      • the version number "1.01A" will become "1.01B".
      • the version number "A14Z" will become "A15A".
  5. Specify the other files that must be included in the ".jar" archive. You can select the JDBC drivers used to access a database for example. Go to the next step.
  6. Define the signature parameters of the Java archive.
    • File of keys.
    • Associated password.
    • Name of key in the file.
    • Password of the key.
  7. Define the parameters for deploying the Java Web Start application:
    • Deployment URL.
    • Directory corresponding to the URL.
  8. Specify:
    • the command of the Java compiler to use. To customize this parameter (if several compilers are installed on the computer for example), select "Custom". In this screen, you can also specify the command line that will be used (see the documentation about the compiler for more details).
    • the command for creating the archive. The "Custom" option allows you to define the tool that will be used to create the archive. You can also specify the command line that will be used (see the documentation of the compiler for more details) and the content of archive manifest.
    • the command for including other archives. The "Custom" option allows you to define the tool that will be used to extract the archive as well as its command line.
    • the command for generating the archive file. The "Custom" option allows you to define the tools that will be used to generate the file of keys.
    • the command for signing the archive. The "Custom" option allows you to define the tool that will be used to sign the archive as well as its command line.
  9. The creation of the Java applet is completed.
The corresponding file was created in the "EXE" directory of project. To run the test of this applet, start the HTML page for test. This page is used to install the client Java application.The corresponding file was created in a sub-directory corresponding to the Java project configuration (sub-directory of EXE directory of project). To run the test of this applet, start the HTML page for test. This page is used to install the client Java application.
Note: See Java and database for more details.
Related Examples:
WD JavaMail Training (WINDEV): WD JavaMail
[ + ] This example is a Java example used to create an applet.
This applet can then be used in an Internet page.
This applet enables you read and send emails.
In this project, a second configuration enables you to manage a "Standard" Java application (.jar).
To generate the Java applet and the "Standard" Java application, select "Workshop - Java - Generate the Java archive",
for each one of the two configurations of project.
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment