annotate Sphinx/source/plugins/java.rst @ 1113:a588960a72e5 default tip

spelling
author Alain Mazy <am@orthanc.team>
date Mon, 28 Oct 2024 09:23:08 +0100
parents 9fdd3714efc1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _java-plugin:
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 Java plugin for Orthanc
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 =======================
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 .. contents::
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 Overview
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 --------
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 This plugin can be used to write :ref:`Orthanc plugins
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 <creating-plugins>` using the `Java programming language
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 <https://en.wikipedia.org/wiki/Java_(programming_language)>`__ instead
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 of the more complex C/C++ programming languages.
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
18 Java applications for Orthanc have access to more features and a more
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
19 consistent SDK than :ref:`Lua scripts <lua>`. The largest part of the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
20 Java API is automatically generated from the `Orthanc plugin SDK in C
1075
d2be251975d1 Orthanc 1.12.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1055
diff changeset
21 <https://orthanc.uclouvain.be/hg/orthanc/file/Orthanc-1.12.4/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h>`__
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 using the `Clang <https://en.wikipedia.org/wiki/Clang>`__ compiler
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 front-end.
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
1090
9fdd3714efc1 python 4.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1081
diff changeset
25 As of release 1.0 of the plugin, **the coverage of the C SDK is about
9fdd3714efc1 python 4.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1081
diff changeset
26 74%** (122 functions are automatically wrapped in Java out of a total
9fdd3714efc1 python 4.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1081
diff changeset
27 of 165 functions from the Orthanc SDK 1.10.0).
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
1055
ebe3214f3ab0 added citation instructions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1021
diff changeset
29 **For researchers**: `Please cite this paper
ebe3214f3ab0 added citation instructions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1021
diff changeset
30 <https://doi.org/10.5220/0012384600003657>`__.
ebe3214f3ab0 added citation instructions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1021
diff changeset
31
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
1081
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
33 How to get it ?
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
34 ---------------
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
35
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
36 Binaries are included in:
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
37
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
38 - The `orthancteam/orthanc Docker image <https://hub.docker.com/r/orthancteam/orthanc>`__
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
39 - The `Windows Installer <https://www.orthanc-server.com/download-windows.php>`__
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
40
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
41 Release notes are available `here <https://orthanc.uclouvain.be/hg/orthanc-java/file/tip/NEWS>`__.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
42
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
43 Compilation instructions are available below.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
44
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
45
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 Source code
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 -----------
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 * Link to the `official releases of this plugin
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 <https://orthanc.uclouvain.be/downloads/sources/orthanc-java/index.html>`__.
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 * Link to the `code repository
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 <https://orthanc.uclouvain.be/hg/orthanc-java/>`__.
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
56 Compilation
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
57 -----------
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
58
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
59 The Java plugin for Orthanc implies the compilation of two modules:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
60
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
61 - The **plugin shared library**, which is needed for all users to run
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
62 Java applications from within Orthanc, and
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
63
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
64 - The **Orthanc Java SDK**, which is needed for developers of Java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
65 applications for Orthanc.
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
66
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
67
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
68 .. _java_shared_library:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
69
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
70 Shared library
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
71 ^^^^^^^^^^^^^^
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
72
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
73 .. highlight:: text
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
74
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
75 If targeting **GNU/Linux distributions**, compiling the shared library
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
76 of the Java plugin (which is written in C++) works as follows::
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
77
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
78 $ mkdir BuildPlugin
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
79 $ cd BuildPlugin
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
80 $ cmake ../Plugin -DCMAKE_BUILD_TYPE=Release
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
81 $ make
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
82
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
83 This requires the `JNI (Java Native Interface)
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
84 <https://en.wikipedia.org/wiki/Java_Native_Interface>`__ to be
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
85 installed on your system (on Ubuntu setups, you can simply install the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
86 ``default-jdk`` package). This produces the ``libOrthancJava.so``
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
87 shared library. This shared library depends on the very specific
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
88 configuration of your system, so precompiled binaries are not
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
89 available.
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
90
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
91 If targeting **Microsoft Windows**, the supported way of compiling the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
92 plugin consists in using the MinGW toolchains to cross-compile the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
93 shared library on a GNU/Linux host::
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
94
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
95 $ mkdir BuildWindows64
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
96 $ cd BuildWindows64
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
97 $ cmake ../Plugin -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release \
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
98 -DCMAKE_TOOLCHAIN_FILE=../Resources/Orthanc/Toolchains/MinGW-W64-Toolchain64.cmake
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
99 $ make
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
100
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
101 This produces the ``libOrthancJava.dll`` shared library. Contrarily to
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
102 GNU/Linux distributions, precompiled binaries are available:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
103
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
104 * For `Microsoft Windows 32 <https://orthanc.uclouvain.be/downloads/windows-32/orthanc-java/index.html>`__, and
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
105 * For `Microsoft Windows 64 <https://orthanc.uclouvain.be/downloads/windows-64/orthanc-java/index.html>`__.
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
106
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
107
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
108 .. _java_sdk:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
109
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
110 Java SDK
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
111 ^^^^^^^^
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
112
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
113 In addition to the shared library that is needed by all the users, the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
114 developers of Java applications for Orthanc need a set of Java classes
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
115 that provide access to the native functions of the Orthanc plugin SDK.
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
116
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
117 The Orthanc Java SDK is available in the folder ``JavaSDK`` of the
1078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
118 source distribution. A ``.jar`` file containing the Orthanc Java SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
119 can be compiled as follows::
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
120
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
121 $ mkdir BuildJavaSDK
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
122 $ cd BuildJavaSDK
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
123 $ cmake ../JavaSDK
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
124 $ make
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
125
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
126 This requires a JDK to be installed on your computer. This generates
1078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
127 the file ``OrthancJavaSDK.jar``. Alternatively, this cross-platform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
128 ``.jar`` library is available in a precompiled form at:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
129
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
130 * The `following location
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
131 <https://orthanc.uclouvain.be/downloads/cross-platform/orthanc-java/index.html>`__
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
132 (evidently, make sure to download the version that matches your
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
133 version of the ``libOrthancJava.so|.dll`` shared library).
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
134
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
135
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
136 Usage
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
137 -----
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
138
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
139 Here is a minimal example of a Java application for Orthanc:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
140
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
141 .. literalinclude:: java/HelloWorld.java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
142 :language: java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
143
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
144 If both the :ref:`shared library <java_shared_library>` and the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
145 :ref:`Java SDK <java_sdk>` are located in the current directory, here
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
146 is a :ref:`configuration file <configuration>` to run this sample Java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
147 application on a GNU/Linux distribution:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
148
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
149 .. literalinclude:: java/HelloWorld.json
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
150 :language: json
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
151
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
152 Orthanc can then be started as follows (the path to ``libjvm.so`` must
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
153 be adapted depending on your configuration)::
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
154
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
155 $ javac HelloWorld.java -classpath ./OrthancJavaSDK.jar
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
156 $ LD_PRELOAD=/usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so ./Orthanc ./HelloWorld.json
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
157
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
158 On Microsoft Windows, one would use the following configuration file
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
159 (beware of the ``:`` that is replaced by ``;`` in the ``Classpath``
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
160 option):
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
161
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
162 .. literalinclude:: java/HelloWorldWindows.json
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
163 :language: json
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
164
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
165 This example simply outputs a line in the logs of Orthanc. Indeed, the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
166 ``static`` section of the class that is specified in the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
167 ``InitializationClass`` option is executed during the initialization
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
168 of the plugin.
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
169
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
170 You can find the full **Javadoc documentation of the Orthanc Java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
171 SDK** `at the following location
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
172 <https://orthanc.uclouvain.be/javadoc/>`__.
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
173
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
174
1081
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
175 Troubleshooting
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
176 ---------------
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
177
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
178 Microsoft Windows
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
179 .................
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
180
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
181 Pre-compiled binaries for Microsoft Windows are now part of the
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
182 `Windows installers <https://www.orthanc-server.com/download-windows.php>`__
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
183 but not installed by default. They are also `available here
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
184 <https://orthanc.uclouvain.be/downloads/windows-64/orthanc-java/index.html>`__.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
185
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
186 Pay also attention to pick the right 32/64 bits version. If you are
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
187 running Orthanc 64bits, install Java in 64bits and select the 64bits
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
188 Java plugin too.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
189
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
190 When you install Java on your Windows machine, make sure to add the path to
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
191 ``jvm.dll`` to your ``Path`` environment variable for at ``System`` level, not user level.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
192 E.g: ``C:\Program Files\Java\jre-1.8\bin\server\``.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
193
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
194 If you get the following error::
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
195
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
196 LoadLibrary(C:\Program Files\Orthanc Server\Plugins\OrthancJava.dll) failed: Error 126
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
197
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
198 This very likely means that OrthancJava.dll can not find the ``jvm.dll``. Check your system ``Path``.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
199
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
200
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
201 If you get the following errors::
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
202
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
203 LoadLibrary(C:\Program Files\Orthanc Server\Plugins\OrthancJava.dll) failed: Error 193
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
204 Error while using a shared library (plugin): You are most probably trying to load a 32bit plugin into a 64bit version of Orthanc
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
205
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
206 This very likely means that Java 32bits has been installed on a 64bits version of Windows.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
207
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
208 `Process Monitor <https://learn.microsoft.com/en-us/sysinternals/downloads/procmon>`__
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
209 should allow you to debug this type of errors.
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
210
649d180ed8ad Java binaries + windows troubleshooting
Alain Mazy <am@orthanc.team>
parents: 1078
diff changeset
211
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
212 Examples
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
213 --------
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
214
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
215 Adding a route in the REST API of Orthanc
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
216 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
217
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
218 New routes can be added to the REST API of Orthanc as follows:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
219
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
220 .. literalinclude:: java/ExtendingRest.java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
221 :language: java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
222
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
223 Reacting to events
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
224 ^^^^^^^^^^^^^^^^^^
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
225
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
226 Java applications can react to Orthanc events as follows:
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
227
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
228 .. literalinclude:: java/Changes.java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
229 :language: java
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
230
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
231
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
232 Additional samples
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
233 ^^^^^^^^^^^^^^^^^^
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
234
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
235 More advanced samples using Maven can be found `in the source
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
236 distribution of the Java plugin
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
237 <https://orthanc.uclouvain.be/hg/orthanc-java/file/default/Samples>`__.
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
238
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
239
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
240 FHIR server for Orthanc
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
241 -----------------------
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
242
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
243 Instructions for using the sample FHIR server for Orthanc that is
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
244 described in the `reference paper
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
245 <https://doi.org/10.5220/0012384600003657>`__ can be found in the
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
246 `source distribution
1078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
247 <https://orthanc.uclouvain.be/hg/orthanc-java/file/default/Samples/FHIR/>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
248
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
249 A precompiled version of the FHIR server is also available at the
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
250 `following location
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
251 <https://orthanc.uclouvain.be/downloads/cross-platform/orthanc-java/index.html>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1077
diff changeset
252
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
253
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
254
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 Licensing
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 ---------
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 This plugin is licensed under the terms of the `GPLv3+ license
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 <https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License>`__,
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 which is the same as the core of Orthanc.
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 This has an important consequence: If you distribute Orthanc to
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 clients together with one Java plugin, you **must** disclose the
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
264 source code of your Java plugins to the Orthanc community under the
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 terms of the GPL or AGPL licenses.
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
1077
df28170c2af3 documenting java
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1075
diff changeset
267 We suggest you to put the source code of your Java plugins on the
999
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 dedicated `"OrthancContributed" repository on GitHub
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 <https://github.com/jodogne/OrthancContributed/tree/master/Plugins>`__,
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 and/or to send it to the `Orthanc Users discussion forum
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 <https://discourse.orthanc-server.org>`__.
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
3b62529bfe91 added java plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 Check out the :ref:`FAQ about licensing <licensing>` for more context.