File: using-with-java.md

package info (click to toggle)
mupdf 1.27.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,224 kB
  • sloc: ansic: 335,320; python: 20,906; java: 7,520; javascript: 2,213; makefile: 1,152; xml: 675; cpp: 639; sh: 513; cs: 307; awk: 10; sed: 7; lisp: 3
file content (44 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Using with Java


There is also a Java library, which uses JNI to provide access to the C
library. The Java classes provide an interface very similar to that available
to Javascript. This Java library also powers the Android versions of MuPDF.

## Android

If you want to build an application for Android, you have several options. You
can base it off one of the existing viewers, or build a new app using the Java
library directly.

See the "Using with Android" section to get started using the MuPDF library for
Android.

## Building

Check out (or download) the MuPDF repository.

The Java bindings are in the platform/java directory.

You can build them using make:

	make java

The resulting shared library are in build/java/release. You need to make sure
the Java runtime can find the JAR archive (with class-path) and the native
library (with java.library.path).

To test the bindings you can use the Java shell:

	$ jshell --class-path=build/java/release -R-Djava.library.path=build/java/release
	jshell> import com.artifex.mupdf.fitz.*
	jshell> var doc = Document.openDocument("pdfref17.pdf")
	jshell> System.out.println(doc.countPages())

## Examples

There are several more examples in the Java directory.

To build and run the example Swing viewer:

	make -C platform/java run