Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Developing Java modules



Java modules are Java Jar files. You will need to develop a Java module:
  • The JDK 8 installation[1]
    You will need a JDK. Having only a JRE will not allow you to develop in Java
  • An IDE [2]
    All examples will use Netbeans
  • The framework library (the protoFramework.jar jar file)

Development environment

IDE installation

You should have a working Java 8 installation.

Netbeans installation

You should have a working Netbeans 8.2 or greater installation. Note that you will have to configure Netbeans to point to the JDK, for example in the etc/netbeans.conf file:
      ...
      netbeans_default_userdir="L:/WRK/Java/tools/netbeansCache/8.2/userDir"
      netbeans_default_cachedir="L:/WRK/Java/tools/netbeansCache/8.2/cacheDir"
      ...
      netbeans_jdkhome="L:/WRK/Java/tools/jdk1.8.0_92"
      ...

Creating the project

The project should be a regular Java Class Library project:
newprojectNB

Libraries dependencies

The module does not need any specific dependency for the runtime[3]
Apart of course if it uses specific libraries of course
, but you will need to add the path of the protoFramework.jar jar file in the libraries dependencies of the project for the development itself.

Project structure

Main class file

The associated Jar file don't need to have a main class, because the module will be called by the framework.

Manifest


You will only need to specify a manifest for the module if:
  • The module use specific Java libraries[4]
    As it is the case for any Jar file, you will need in that case to add a Class-Path attribute in the manifest, but there is no framework specificity
  • You want to set properties which specify default application, services or types configurations
As explained in the Libraries dependencies paragraph, you don' t need to add the path to the protoFramework.jar jar file in the libraries dependencies in the manifest file.

Starting the module in the IDE

You can start the module through the framework in the IDE by adding an ant target to the Nebeans ant build.xml script.

Producing more than one jar file in the project

By default there is only one jar file associated with the project. You execute the build by clicking on the nbBuild button.

The jar file will be generated in the dist sub-directory and its name will be the name of the project.

For example, with the following project:
NBProjectLibrary2
you will only have the MyProject.jar jar file in the dist sub-directory.

It is possible to prpduce more than one jar file by editing the xml file. For example to produce two jar files for the first tutorial:

      <target depends="init,compile,-pre-jar,-do-jar-without-manifest,-post-jar" description="Build JAR." name="jar"/>
      <target name="-do-jar-without-manifest" depends="-samplePublish, -sampleEvent" />

      <target name="-samplePublish" depends="init,compile,-pre-pre-jar,-pre-jar" >
         <jar description="jar binary file" compress="true" jarfile="${dist.dir}/samplesPublish.jar">
            <fileset defaultexcludes="yes" dir="${build.classes.dir}" >
               <include name="org/da/samples/protoframework/publish/**/*.class"/>
            </fileset>
         </jar>
      </target>
   
      <target name="-sampleEvent" depends="init,compile,-pre-pre-jar,-pre-jar" >
         <jar description="jar binary file" compress="true" jarfile="${dist.dir}/samplesEvents.jar">
            <fileset defaultexcludes="yes" dir="${build.classes.dir}" >
               <include name="org/da/samples/protoframework/event/**/*.class"/>
            </fileset>
         </jar>
      </target>

Adding a runtime ant target

      <target name="Start my Module" description="Start my Module" depends="init" >
         <java classname="org.da.protoframework.model.core.Framework">
            <arg value="config=<path_to_the_configuration>/filelist.xml"/>
            <classpath>
               <pathelement path="<path_to_the_framework>/protoframework.jar"/>
               <pathelement path="<path_to_the_framework>/lib/MDIUtilities-ui-LGPL.jar"/>
            </classpath>
         </java>
      </target>

Adding a debug ant target

      <target depends="init" name="Debug my Module" description="Debug my Module" >
         <property name="debug.class" value="org.da.protoframework.model.core.Framework"/>
         <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
         <j2seproject1:nbjpdastart name="${debug.class}"/>
         <j2seproject3:debug classname="${debug.class}">
            <customize>
               <arg line="config=<path_to_the_configuration>/filelist.xml"/>
            </customize>
         </j2seproject3:debug>
      </target>
Note that if you add a debug ant target, you will need to define the declaration for j2seproject1: and j2seproject3. For example:
      <project name="myModule" default="default" basedir="."
      xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1"
      xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" >
      ...
       <project>

Notes

  1. ^ You will need a JDK. Having only a JRE will not allow you to develop in Java
  2. ^ All examples will use Netbeans
  3. ^ Apart of course if it uses specific libraries of course
  4. ^ As it is the case for any Jar file, you will need in that case to add a Class-Path attribute in the manifest, but there is no framework specificity

See also


Categories: development

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence