Matrex is composed by several jars:
Here is the typical content of a batch file starting Matrex (it uses the two variables MATREX_CP and LIB_CP):
This approach has several problems:
In these days I worked on a new approach. The idea is to have 3 files containing the list of jars needed to start Matrex:
matrex_api.jar
matrex_fun.jar
matrex_gui.jar
To load these files and to load the jars listed in them, Matrex uses a custom class loader, TextFilesClassLoader.
The start class of Matrex is now called MatrexLoader.
MatrexLoader loads the main class of Matrex, Start, using TextFilesClassLoader as class loader.
Since Start all the other classes of Matrex (included the ones in the library) are loaded, directly or indirectly, from Start, they all use the same class loader used by Start, TextFilesClassLoader.
In this way it has been also possible to write a special Matrex GUI dialog, PluginsDialog, to update the content of plugins.cld:
This is much easier than to change manually the batch file.
- The Matrex jars: api, gui, fun.
- The libraries used by Matrex, for example SWT, jfreechart.
- The plug-ins, for example the library to connect Matrex to Matlab.
Here is the typical content of a batch file starting Matrex (it uses the two variables MATREX_CP and LIB_CP):
MATREX_CP=matrex_api.jar:matrex_fun.jar:matrex_gui.jar
LIB_CP=freehepj3d.jar:jython.jar:commons-math-1.1.jar:jfreechart-1.0.8a.jar:jcommon-1.0.12.jar:jxl.jar:lucene-core-2.0.0.jar:swt/swt.jar:antlr-runtime-3.0.1.jar:javacsv.jar:net.sf.paperclips_1.0.2.jar
java -Djava.library.path=swt -Djava.util.logging.config.file=logging.properties -classpath $MATREX_CP:$LIB_CP matrex.gui.Start $1
This approach has several problems:
- It is not readable, and it becomes less readable adding more libraries.
- If the user wants to add a plug-in, he has to edit the batch file. This is unconfortable, because the user needs to learn the syntax of the batch file, and dangerous: if the user does a small mistake changing the batch file the program does not start.
- you need to have one copy of this batch file for each platform in which Matrex is released (Windows, Linux, MacOSX...).
In these days I worked on a new approach. The idea is to have 3 files containing the list of jars needed to start Matrex:
- matrex.cld containing the main Matrex jars
- libraries.cld containing the libraries used by Matrex
- plugis.cld containing the plug-ins (it is empty when Matrex is installed)
matrex_api.jar
matrex_fun.jar
matrex_gui.jar
To load these files and to load the jars listed in them, Matrex uses a custom class loader, TextFilesClassLoader.
The start class of Matrex is now called MatrexLoader.
MatrexLoader loads the main class of Matrex, Start, using TextFilesClassLoader as class loader.
Since Start all the other classes of Matrex (included the ones in the library) are loaded, directly or indirectly, from Start, they all use the same class loader used by Start, TextFilesClassLoader.
In this way it has been also possible to write a special Matrex GUI dialog, PluginsDialog, to update the content of plugins.cld:
This is much easier than to change manually the batch file.
No comments:
Post a Comment