4 Installation¶
In this section we discuss how to install and setup the MOSEK Fusion API for Java.
Important
Before running this MOSEK interface please make sure that you:
Installed MOSEK correctly. Some operating systems require extra steps. See the Installation guide for instructions and common troubleshooting tips.
Set up a license. See the Licensing guide for instructions.
Compatibility
The Fusion API for Java is compatible with Java version 1.8 or later on 64bit platforms (Linux, Windows, macOS).
Locating files in the MOSEK Optimization Suite
The relevant files of the Fusion API for Java are organized as reported in Table 4.1.
Relative Path |
Description |
Label |
---|---|---|
|
Libraries and jar file |
|
|
Examples |
|
|
Additional data |
|
where
<MSKHOME>
is the folder in which the MOSEK Optimization Suite has been installed,<PLATFORM>
is the actual platform among those supported by MOSEK, i.e.win64x86
,linux64x86
orosx64x86
.
Setting up paths
To compile and run a Java program using MOSEK the correct path to <JARDIR>/mosek.jar
must be provided in the Java classpath. This is usually set with the command line option
javac -d . -classpath <JARDIR>/mosek.jar lo1.java
java -classpath .:<JARDIR>/mosek.jar com.mosek.example.lo1
Alternatively, this can be set with the environment variable CLASSPATH
. For more information about specifying class libraries and compiling applications, see the full Java documentation at http://java.sun.com/.
4.1 Building Examples and Testing the Installation¶
This section describes how to verify that MOSEK has been installed correctly, and how to build and execute the Java examples distributed with MOSEK.
4.1.1 Windows¶
Building and executing a program
To compile the example lo1.java
distributed with MOSEK:
Open a DOS prompt and go to the examples directory
<EXDIR>
.To compile a Java program and produce the class files in the current directory, type
javac -classpath <JARDIR>\mosek.jar -d . lo1.java
To run the compiled program, type
java -classpath .:<JARDIR>\mosek.jar com.mosek.example.lo1
Compiling with Microsoft NMake
The distributed examples can also be compiled using Microsoft NMake. This requires that paths and environment is set up for Visual Studio tools (usually, the sub-menu containing Visual Studio also contains a Visual Studio Command Prompt which take care of all the necessary setup).
To build the examples, open a DOS box and change directory to the examples directory <EXDIR>
. To compile all examples type
nmake /f Makefile
This will compile all the classes into a jar
file. To run all the examples type
nmake /f Makefile test
4.1.2 macOS and Linux¶
Building and executing a program
To compile the example lo1.java
distributed with MOSEK:
Open a console and go to the examples directory
<EXDIR>
.To compile a Java program and produce the class files in the current directory, type
javac -classpath <JARDIR>/mosek.jar -d . lo1.java
To run the compiled program, type
java -classpath .:<JARDIR>/mosek.jar com.mosek.example.lo1
Compiling examples using make
The example directory contains makefiles for use with GNU Make. To build the examples, open a prompt and change directory to the examples directory <EXDIR>
. To compile all examples type
make -f Makefile
This will compile all the classes into a jar
file. To run all the examples type
make test