/**

\page tutorial-install-java Tutorial: Installing ViSP for Java
\tableofcontents

\section java_intro 1. Introduction

At this point we suppose that you succeed to build ViSP from source following one \ref tutorial_install_src tutorials.

This tutorial will help you to build ViSP from source for Java on your desktop. It shows how to proceed if your desktop
is running Linux, OSX or Windows.

\section java_ws 2. Create a workspace

\subsection java_ws_unix 2.1. On Ubuntu, Debian or Mac OSX

First create a workspace in `$HOME/visp-ws` that will contain ViSP sources, build and dataset.
\code{.sh}
$ export VISP_WS=$HOME/visp-ws
$ mkdir -p $VISP_WS/3rdparty
\endcode

\subsection java_ws_win 2.2. On Windows

Follow instructions to \ref install_win11_msvc17_ws on Windows.

We suppose now that you have set `%%VISP_WS%` var.

\section java_install_jdk 3. Install Java Development Kit (JDK)

\note At the time this tutorial was updated, the lastest Long Term Support Java SE Development Kit (JDK) is version 21.
Here we recall \ref java_install_tips_uninstall_jdk if you need to upgrade or downgrade JDK version.

\subsection java_install_jdk_unix 3.1. On Ubuntu or Debian

From the [Oracle](http://www.oracle.com/technetwork/java/javase/downloads/index.html) website, download JDK 21 the
latest Long Term Support release of the Java SE Platform. There exists also JDK 23 the latest release, but we
experienced issues when using it in an Eclipse project on Ubuntu. That's why at the time this tutorial was updated, we
considered JDK 21 and downloaded `jdk-21_linux-x64_bin.tar.gz` file.
After JDK download and extraction of the files from the archive, you may set `JAVA_HOME` environment var to help `cmake`
to detect JDK.
\code{.sh}
$ tar xvzf ~/Downloads/jdk-21_linux-x64_bin.tar.gz -C $VISP_WS/3rdparty
$ echo 'export JAVA_HOME=$VISP_WS/3rdparty/jdk-21.0.6' >> ~/.bashrc
$ echo 'export PATH=${JAVA_HOME}/bin:${PATH}' >> ~/.bashrc
$ source ~/.bashrc
\endcode

After installation check JDK version:
\code{.sh}
$ java --version
java 21.0.6 2025-01-21 LTS
Java(TM) SE Runtime Environment (build 21.0.6+8-LTS-188)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.6+8-LTS-188, mixed mode, sharing)
\endcode

\subsection java_install_jdk_osx 3.2. On Mac OSX

There are two different ways to install JDK on Mac OSX. We recommend the way using DMG installer.

<b>3.2.1. Install JDK with DMG installer</b>

Navigate to [Oracle](http://www.oracle.com/technetwork/java/javase/downloads/index.html) website and download the
DMG installer that match your OS. At the time this tutorial was updated, we downloaded `jdk-23_macos-aarch64_bin.dmg`
that corresponds to the JDK 23 version for a Macbook Pro M1.

After installation, check that JDK and java are well detected:
\code{.sh}
$ java -version
java version "23.0.2" 2025-01-21
\endcode

<b>3.2.2. Install OpenJDK with brew</b>

\note If you already have an old JDK version you may remove it before installing OpenJDK:
\code{.sh}
$ ls /Library/Java/JavaVirtualMachines/
jdk-11.0.10.jdk
\endcode
Here it shows that `jdk-11.0.10` is installed. To remove this version, see \ref java_install_tips_uninstall_jdk.

To install OpenJDK with brew:

- run:
\code{.sh}
$ brew install openjdk
\endcode

- To know which version is installed:
\code{.sh}
$ brew info openjdk
openjdk: stable 23.0.2 (bottled) [keg-only]
\endcode

- Now for the system Java wrappers to find this JDK, symlink it with:
\code{.sh}
$ sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
\endcode
\note Depending on the OpenJDK version, the symlink instruction can differ. To know which one is to use, follow
instructions provided by `brew info openjdk`. At the time this tutorial was updated, we got:
\code{.sh}
$ brew info openjdk
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
\endcode

- Set `JAVA_HOME` env var to help JNI headers and libraries detection
\code{.sh}
$ echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.zshrc
$ source ~/.zshrc
\endcode

- After installation check that OpenJDK and java are well detected:
\code{.sh}
$ java --version
openjdk 23.0.2 2025-01-21
\endcode

\subsection java_install_jdk_win 3.3. On Windows

From the [Oracle](http://www.oracle.com/technetwork/java/javase/downloads/index.html) website, download JDK 23 to get
`jdk-23_windows-x64_bin.exe` and run the binary. In order to make `java.exe` available, we had also to add its location
`C:\Program Files\Java\jdk-17.0.2\bin` to the `%%PATH%` environment variable.

After installation check JDK version:
\code{.sh}
C:\> java -version
java version 23.0.2 2025-01-21
\endcode

\section java_eclipse 4. Install the latest Eclipse version

Download the latest Eclipse version at the [Eclipse Download page](https://www.eclipse.org/downloads/eclipse-packages/)
choosing the <b> Eclipse IDE for Java Developers </b> version.

\subsection java_eclipse_unix 4.1. On Ubuntu, Debian and Mac OSX

On Ubuntu, Debian or Mac OSX you don’t need to install anything. Extract the downloaded compressed file and put the
resulting folder wherever you want to, for example in `$VISP_WS/3rdparty/eclipse`.

We suppose here that you have Eclipse installed `$VISP_WS/3rdparty/eclipse`:
\code{.sh}
$ ls $VISP_WS/3rdparty/eclipse
artifacts.xml  configuration  dropins  eclipse  eclipse.ini  features  icon.xpm  p2  plugins  readme
\endcode

\subsection java_eclipse_win 4.2. On Windows

After downloading Eclipse simply open the installer and follow default installation instructions.
At the time this tutorial was updated we downloaded `"Eclipse IDE 2024-12 R"`, getting `eclipse-inst-jre-win64.exe`
installer.

Eclipse was installed by default in `C:\Users\%USERNAME%\eclipse\java-2024-12\eclipse` folder.

\section java_prereq 5. Install Prerequisites

To build ViSP for java you have also to install [CMake](http://www.cmake.org/download/),
[Apache Ant](http://ant.apache.org/), and [Python 3](https://www.python.org/downloads/).
If you don’t have any of these do the following:

\subsection java_prereq_ubuntu 5.1. On Ubuntu/Debian
\code{.sh}
$ sudo apt-get install cmake-curses-gui ant python3
\endcode

\subsection java_prereq_fedora 5.2. On Fedora/CentOS
\code{.sh}
$ sudo dnf install gcc-c++ cmake ant python3
\endcode

\subsection java_prereq_mac 5.3. On Mac OSX
\code{.sh}
$ brew install cmake ant python3
\endcode

\subsection java_prereq_win 5.4. On Windows
- Download the latest CMake release for Windows win64-x64 platform from http://www.cmake.org. At the time this
  tutorial was written it was the file cmake-4.0.0-rc1-windows-x86_64.msi. To install just double click on the msi file.
- Download the latest Python 3 release for Windows from https://www.python.org/downloads/. At the time this tutorial
  was written, it was Python 3.13.2.
- There is also Apache Ant that is needed. Download Apache Ant binary distribution from
  https://ant.apache.org/bindownload.cgi. At the time this tutorial was updated we downloaded
  `apache-ant-1.10.15-bin.zip` file. Unzip the file for example in `C:\Users\%USERNAME%\apache-ant-1.10.15-bin`.
  To help Ant detection, set `ANT_HOME` var to your installation folder. In our case it becomes
\code{.sh}
C:\> setx ANT_HOME C:\Users\%USERNAME%\apache-ant-1.10.15-bin
\endcode
  You need also to add `"%ANT_HOME%\bin"` to the `"Path"` environment variable. To this end, open the environment
  variables panel, and modify `"Path"` accordingly. In our case we added
  `"C:\Users\%USERNAME%\apache-ant-1.10.15-bin\bin"` folder.
  \note You can check that the `"%ANT_HOME%"` variable is correctly positioned by checking that the `ant.bat` file is
  in the `"%ANT_HOME%\bin"` folder.

\section install_java_visp 6. Build ViSP from source code

\subsection install_java_visp_get_source 6.1. Getting ViSP source code

There are different ways to get ViSP source code:

- You can download the <a href="https://visp.inria.fr/download">latest release</a> as a zip or a tarball. Once
  downloaded, uncompress the file using either
\code{.sh}
$ tar xvzf visp-x.y.z.tar.gz -C $VISP_WS
\endcode
or
\code{.sh}
$ unzip visp-x.y.z.zip -d $VISP_WS
\endcode

- You can also download a <a href="https://visp.inria.fr/download#snapshot">daily snapshot</a>. Once downloaded,
  uncompress the file using
\code{.sh}
$ tar xvzf visp-snapshot-yyyy-mm-dd.tar.gz -C $VISP_WS
\endcode

- Or you get the cutting-edge ViSP from <a href="https://github.com/lagadic/visp">GitHub repository</a> using the
  following command
\code{.sh}
$ cd $VISP_WS
$ git clone https://github.com/lagadic/visp.git
\endcode

We suppose now that ViSP source is in the directory `$VISP_WS/visp`. The following should be adapted if you downloaded
ViSP from a zip or tarball. In that case, the source is rather in something like `$VISP_WS/visp-x.y.z`.

\subsection install_java_visp_config 6.2. Configuring ViSP from source

- In the workspace, create first a directory named `visp-build` that will contain all the build material; generated
  Makefiles or Visual Studio Solution files, object files, output libraries and binaries once build is done, and in a
  second stage configure ViSP using CMake.
  - **On Ubuntu/Debian like and on macOS**
\code{.sh}
$ mkdir $VISP_WS/visp-build
$ cd $VISP_WS/visp-build
$ cmake ../visp
\endcode
  - **On Windows**
\code{.sh}
C:\> mkdir %VISP_WS%\visp-build
C:\> cd %VISP_WS%\visp-build
C:\> cmake -G "Visual Studio 17 2022" -A "x64" %VISP_WS%\visp
\endcode

- At this point, in `$VISP_WS/visp-build/ViSP-third-party.txt` you should find something similar to the following
  snapshot that shows that `python`, `ant` and `JNI` are found:
  - **On Ubuntu/Debian like**
\code{.sh}
==========================================================
General configuration information for ViSP 3.6.1

  Version control:               v3.6.0-2170-g800e1426c-dirty

  Platform:
    Timestamp:                   2025-02-17T14:47:03Z
    Host:                        Linux 6.8.0-52-generic x86_64
    CMake:                       3.28.3
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/gmake
    Configuration:               Release

  System information:
    Number of CPU logical cores: 32
    Number of CPU physical cores: 24
    Total physical memory (in MiB): 31774
    OS name:                     Linux
    OS release:                  6.8.0-52-generic
    OS version:                  #53-Ubuntu SMP PREEMPT_DYNAMIC Sat Jan 11 00:06:25 UTC 2025
    OS platform:                 x86_64
    CPU name:                    Unknown P6 family
    CPU description:             24 core 13th Gen Intel(R) Core(TM) i9-13950HX
    Is the CPU 64-bit?           yes
    Does the CPU have FPU?       yes
    CPU optimization:            SSE2 SSE3 SSSE3
    CPU endianness:              little-endian

  C/C++:
    Built as dynamic libs?:      yes
    C++ Compiler:                /usr/bin/c++  (ver 13.3.0)
    C++ flags (Release):         -Wall -Wextra -fopenmp -std=c++17 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -O3 -DNDEBUG
    C++ flags (Debug):           -Wall -Wextra -fopenmp -std=c++17 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -g
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -Wall -Wextra -fopenmp -std=c++17 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -O3 -DNDEBUG
    C flags (Debug):             -Wall -Wextra -fopenmp -std=c++17 -fvisibility=hidden -msse2 -msse3 -mssse3 -fPIC -g
    Linker flags (Release):
    Linker flags (Debug):
    Use cxx standard:            17

  ViSP modules:
    To be built:                 core dnn_tracker gui imgproc io java_bindings_generator klt me sensor ar blob robot visual_features vs vision detection mbt rbt tt tt_mi java
    Disabled:                    -
    Disabled by dependency:      -
    Unavailable:                 -
    Enable visp namespace:       no
    Enable explicit keyword:     no

  Python 3:
    Interpreter:                 /home/username/miniforge3/bin/python3 (ver 3.12.7)

  Java:
    ant:                         /usr/bin/ant (ver 1.10.14)
    Java:                        no
    JNI:                         /home/username/visp-ws/3rdparty/jdk-21.0.6/include /home/username/visp-ws/3rdparty/jdk-21.0.6/include/linux /home/username/visp-ws/3rdparty/jdk-21.0.6/include
    Java wrappers:               yes (ANT)
\endcode

  - **On macOS**
\code{.sh}
$ more ViSP-third-party.txt
==========================================================
General configuration information for ViSP 3.6.1

  Version control:               4471cea29-dirty

  Platform:
    Timestamp:                   2025-02-18T16:42:59Z
    Host:                        Darwin 24.3.0 arm64
    CMake:                       3.31.5
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  System information:
    Number of CPU logical cores: 10
    Number of CPU physical cores: 10
    Total physical memory (in MiB): 32768
    OS name:                     macOS
    OS release:                  15.3.1
    OS version:                  24D70
    OS platform:                 arm64
    CPU name:                    Apple M1 Pro
    CPU description:             10 core Apple M1 Pro
    Is the CPU 64-bit?           yes
    Does the CPU have FPU?       yes
    CPU optimization:            NEON
    CPU endianness:              little-endian

  C/C++:
    Built as dynamic libs?:      yes
    C++ Compiler:                /Library/Developer/CommandLineTools/usr/bin/c++  (ver 16.0.0.16000026)
    C++ flags (Release):         -Wall -Wextra -Xclang -fopenmp -std=c++17 -fvisibility=hidden -fPIC -O3 -DNDEBUG
    C++ flags (Debug):           -Wall -Wextra -Xclang -fopenmp -std=c++17 -fvisibility=hidden -fPIC -g
    C Compiler:                  /Library/Developer/CommandLineTools/usr/bin/cc
    C flags (Release):           -Wall -Wextra -Xclang -fopenmp -std=c++17 -fvisibility=hidden -fPIC -O3 -DNDEBUG
    C flags (Debug):             -Wall -Wextra -Xclang -fopenmp -std=c++17 -fvisibility=hidden -fPIC -g
    Linker flags (Release):
    Linker flags (Debug):
    Use cxx standard:            17

  ViSP modules:
    To be built:                 core dnn_tracker gui imgproc io java_bindings_generator klt me sensor ar blob robot visual_features vs vision detection mbt rbt tt tt_mi java
    Disabled:                    -
    Disabled by dependency:      -
    Unavailable:                 -
    Enable visp namespace:       no
    Enable explicit keyword:     no

  Python 3:
    Interpreter:                 /Users/user/miniforge3/bin/python3.10 (ver 3.10.13)

  Java:
    ant:                         /opt/homebrew/bin/ant (ver 1.10.15)
    Java:                        no
    JNI:                         /opt/homebrew/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home/include /opt/homebrew/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home/include/darwin /opt/homebrew/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home/include
    Java wrappers:               yes (ANT)
\endcode

  - **On Windows**
\code{.sh}
C:\> type ViSP-third-party.txt
==========================================================
General configuration information for ViSP 3.6.1

  Version control:               564643c39

  Platform:
    Timestamp:                   2025-02-20T17:46:12Z
    Host:                        Windows 10.0.19044 AMD64
    CMake:                       4.0.0-rc1
    CMake generator:             Visual Studio 17 2022
    CMake build tool:            C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
    MSVC:                        1935

  System information:
    Number of CPU logical cores: 4
    Number of CPU physical cores: 4
    Total physical memory (in MiB): 16057
    OS name:                     Windows
    OS release:                  Professional
    OS version:                  (Build 19044)
    OS platform:                 AMD64
    CPU name:                    Pentium II (0.25 micron)
    CPU description:             4 core 3192 MHz GenuineIntel Pentium II (0.25 micron)
    Is the CPU 64-bit?           yes
    Does the CPU have FPU?       yes
    CPU optimization:            SSE2 SSE3 SSSE3 SSE4_1 SSE4_2
    CPU endianness:              little-endian

  C/C++:
    Built as dynamic libs?:      yes
    C++ Compiler:                C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe  (ver 19.35.32215.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W3 /GR /EHsc   /EHa -openmp /Gy /bigobj /MD /O2 /Ob2 /DNDEBUG
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W3 /GR /EHsc   /EHa -openmp /Gy /bigobj /MDd /Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3   /EHa -openmp /MD /O2 /Ob2 /DNDEBUG
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3   /EHa -openmp /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64 /INCREMENTAL:NO
    Linker flags (Debug):        /machine:x64 /debug /INCREMENTAL /ignore:4099
    Use cxx standard:            17

  ViSP modules:
    To be built:                 core dnn_tracker gui imgproc io java_bindings_generator klt me sensor ar blob robot visual_features vs vision detection mbt tt tt_mi java
    Disabled:                    -
    Disabled by dependency:      -
    Unavailable:                 -
    Enable visp namespace:       no
    Enable explicit keyword:     no

  Windows RT support:            no

  Python 3:
    Interpreter:                 C:/Users/user/AppData/Local/Programs/Python/Python313/python.exe (ver 3.13.2)

  Java:
    ant:                         C:/Users/user/apache-ant-1.10.15/bin/ant.bat (ver 1.10.15)
    Java:                        no
    JNI:                         C:/Program Files/Java/jdk-23/include C:/Program Files/Java/jdk-23/include/win32 C:/Program Files/Java/jdk-23/include
    Java wrappers:               yes (ANT)
\endcode

  \note If JNI is not found (ie. the line starting with `JNI:` is empty), we recommend to do a fresh build removing all
  the files in the build folder and configuring again from scratch with CMake.

\subsection install_java_visp_build 6.3. Building ViSP libraries

Depending on you platform, you can now build `visp_java` module:

- **On Ubuntu/Debian like, proceed with:**
\code{.sh}
$ cd $VISP_WS/visp-build
$ make -j$(nproc) visp_java
\endcode

- **On macOS, proceed with:**
\code{.sh}
$ cd $VISP_WS/visp-build
$ make -j$(sysctl -n hw.ncpu) visp_java
\endcode

- **On Windows, proceed with:**
\code{.sh}
C:\> cd %VISP_WS%\visp-build
C:\> cmake --build . --config Release --target visp_java
\endcode

Note that ViSP Java ARchive is now available in `$VISP_WS/visp-build/bin/visp-340.jar`.

\section create_user_library 7. Creating a user library in Eclipse

Open Eclipse and select a workspace location of your choice, for example in `$VISP_WS/eclipse-workspace` and
press `Launch` button.

\image html img-tutorial-java-eclipse-workspace.jpg

Now we propose to create a ViSP user library ready to be used on all your next Java projects. To this end,
- if you are on OS X enter `"Eclipse > Preferences..."` menu
- otherwise enter `"Window > Preferences"` menu:
\image html img-tutorial-java-eclipse1.jpeg Open Preferences panel in Eclipse

In the Preferences panel navigate under `"Java > Build Path > User Libraries"` and choose **New**. Enter a name for the
library (e.g `visp`) and press **OK** button.

\image html img-tutorial-java-eclipse2.jpeg Create a new User Library

Press `"Add External JARs"` button, browse to select <b>`$VISP_WS/visp-build/bin/visp-361.jar`</b> from your computer.

\image html img-tutorial-java-eclipse21.jpg Add external JARs

After adding the jar, select `"Native library location"`, press first `"Edit"`, press `"External Folder"`, browse to
select the folder <b>`$VISP_WS/visp-build/lib`</b> containing ViSP libraries and finally press **OK** button.
We recall that the libraries have the extension <b>.so</b> in linux, <b>.dylib</b> in MacOS and <b>.dll</b> in Windows.

\image html img-tutorial-java-eclipse3.jpg Add native library location

Once done, press `"Apply and Close"` button.

\section java_install_tips 8. Tips & Tricks

\subsection java_install_tips_uninstall_jdk 8.1. How to uninstall JDK

Here we give here some tips to uninstall JDK to be able to downgrade or upgrade JDK version.

- <b>On Ubuntu or Debian platform</b>
  On Ubuntu or Debian platform remove first the folder containing JDK.
\code{.sh}
$ rm -rf $VISP_VS/jdk-11.0.6
\endcode
  Then in `~/.bashrc` remove any reference to `JAVA_HOME` env var deleting the lines similar to:
\code{.sh}
export JAVA_HOME=$VISP_VS/jdk-11.0.6
export PATH=${JAVA_HOME}/bin:${PATH}
\endcode

- <b>On macOS platform</b>
  To uninstall JDK on Mac OSX, you must have administrator privileges and remove the directory whose name matches the
  following format: `/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk`. You can proceed using:
\code{.sh}
$ sudo mv /Library/Java/JavaVirtualMachines/jdk-13.jdk/ /tmp
\endcode
  and/or:
\code{.sh}
$ sudo mv /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/ /tmp
\endcode

- <b>On Windows platform</b>
  To uninstall JDK on Windows, click Start menu, select `"Settings > System > Apps & features"`. Select the program to
  unsinstall like `Java(TM) SE Development Kit 13.0 (64-bit)`, then click its Uninstall button. Respond to the prompts
  to complete the uninstall.

\subsection java_install_tips_rm_workspace 8.2. How to delete an Eclipse workspace

To remove existing Eclipse workspaces, enter `"Preferences > General > Startup & Shudown > Workspaces"` menu, select
the workspace to remove and press `Remove` button and then `Apply and Close` button.

\image html img-tutorial-java-eclipse-remove-workspace.jpeg

Note that this does not actually delete the files from the system, it simply removes it from the list of suggested
workspaces. You need to remove the workspace directory by hand.

\section java_install_next 9. Next tutorial

You are now ready to follow \ref tutorial-java-started.

*/
