-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathjava-deployment.html
More file actions
141 lines (126 loc) · 59.5 KB
/
java-deployment.html
File metadata and controls
141 lines (126 loc) · 59.5 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Java - Java deployment</title>
<meta name="generator" content="VuePress 1.8.2">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="description" content="Making an executable JAR from the command line, Creating JAR, WAR and EAR files, Introduction to Java Web Start, Creating an UberJAR for an application and its dependencies">
<meta property="og:site_name" content="DevTut">
<meta property="og:title" content="Java - Java deployment">
<meta property="og:description" content="Making an executable JAR from the command line, Creating JAR, WAR and EAR files, Introduction to Java Web Start, Creating an UberJAR for an application and its dependencies">
<meta property="og:type" content="article">
<meta property="og:url" content="/java/java-deployment.html">
<meta property="og:image" content="/logo.png">
<meta name="twitter:title" content="Java - Java deployment">
<meta name="twitter:description" content="Making an executable JAR from the command line, Creating JAR, WAR and EAR files, Introduction to Java Web Start, Creating an UberJAR for an application and its dependencies">
<meta name="twitter:url" content="/java/java-deployment.html">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="/logo.png">
<meta name="theme-color" content="#ffffff">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="msapplication-TileImage" content="/mstile-150x150.png">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="google-site-verification" content="76_rKXgwMVIjd-axJC_1zPV9OS4mEjvtgjYOWVkAdnQ">
<link rel="preload" href="/assets/css/0.styles.60619e34.css" as="style"><link rel="preload" href="/assets/js/app.1779e102.js" as="script"><link rel="preload" href="/assets/js/3.2cfa8016.js" as="script"><link rel="preload" href="/assets/js/1588.04d50216.js" as="script">
<link rel="stylesheet" href="/assets/css/0.styles.60619e34.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">DevTut</span></a> <div class="links"><form id="search-form" role="search" class="algolia-search-wrapper search-box"><input id="algolia-search-input" class="search-query"></form> <nav class="nav-links can-hide"> <a href="https://github.com/devtut/generate" target="_blank" rel="noopener noreferrer" class="repo-link">
GitHub
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"> <a href="https://github.com/devtut/generate" target="_blank" rel="noopener noreferrer" class="repo-link">
GitHub
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Java</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/java/" aria-current="page" class="sidebar-link">Disclaimer</a></li><li><a href="/java/java-editions-versions-releases-and-distributions.html" class="sidebar-link">Java Editions, Versions, Releases and Distributions</a></li><li><a href="/java/installing-java-standard-edition.html" class="sidebar-link">Installing Java (Standard Edition)</a></li><li><a href="/java/getting-started-with-java-language.html" class="sidebar-link">Getting started with Java Language</a></li><li><a href="/java/type-conversion.html" class="sidebar-link">Type Conversion</a></li><li><a href="/java/getters-and-setters.html" class="sidebar-link">Getters and Setters</a></li><li><a href="/java/reference-data-types.html" class="sidebar-link">Reference Data Types</a></li><li><a href="/java/java-compiler-javac.html" class="sidebar-link">Java Compiler - 'javac'</a></li><li><a href="/java/documenting-java-code.html" class="sidebar-link">Documenting Java Code</a></li><li><a href="/java/command-line-argument-processing.html" class="sidebar-link">Command line Argument Processing</a></li><li><a href="/java/the-java-command-java-and-javaw.html" class="sidebar-link">The Java Command - 'java' and 'javaw'</a></li><li><a href="/java/literals.html" class="sidebar-link">Literals</a></li><li><a href="/java/primitive-data-types.html" class="sidebar-link">Primitive Data Types</a></li><li><a href="/java/strings.html" class="sidebar-link">Strings</a></li><li><a href="/java/stringbuffer.html" class="sidebar-link">StringBuffer</a></li><li><a href="/java/stringbuilder.html" class="sidebar-link">StringBuilder</a></li><li><a href="/java/string-tokenizer.html" class="sidebar-link">String Tokenizer</a></li><li><a href="/java/splitting-a-string-into-fixed-length-parts.html" class="sidebar-link">Splitting a string into fixed length parts</a></li><li><a href="/java/date-class.html" class="sidebar-link">Date Class</a></li><li><a href="/java/dates-and-time-java-time.html" class="sidebar-link">Dates and Time (java.time.*)</a></li><li><a href="/java/localtime.html" class="sidebar-link">LocalTime</a></li><li><a href="/java/bigdecimal.html" class="sidebar-link">BigDecimal</a></li><li><a href="/java/biginteger.html" class="sidebar-link">BigInteger</a></li><li><a href="/java/numberformat.html" class="sidebar-link">NumberFormat</a></li><li><a href="/java/bit-manipulation.html" class="sidebar-link">Bit Manipulation</a></li><li><a href="/java/arrays.html" class="sidebar-link">Arrays</a></li><li><a href="/java/collections.html" class="sidebar-link">Collections</a></li><li><a href="/java/lists.html" class="sidebar-link">Lists</a></li><li><a href="/java/sets.html" class="sidebar-link">Sets</a></li><li><a href="/java/list-vs-set.html" class="sidebar-link">List vs SET</a></li><li><a href="/java/maps.html" class="sidebar-link">Maps</a></li><li><a href="/java/linkedhashmap.html" class="sidebar-link">LinkedHashMap</a></li><li><a href="/java/weakhashmap.html" class="sidebar-link">WeakHashMap</a></li><li><a href="/java/sortedmap.html" class="sidebar-link">SortedMap</a></li><li><a href="/java/treemap-and-treeset.html" class="sidebar-link">TreeMap and TreeSet</a></li><li><a href="/java/queues-and-deques.html" class="sidebar-link">Queues and Deques</a></li><li><a href="/java/dequeue-interface.html" class="sidebar-link">Dequeue Interface</a></li><li><a href="/java/enums.html" class="sidebar-link">Enums</a></li><li><a href="/java/enum-map.html" class="sidebar-link">Enum Map</a></li><li><a href="/java/enumset-class.html" class="sidebar-link">EnumSet class</a></li><li><a href="/java/enum-starting-with-number.html" class="sidebar-link">Enum starting with number</a></li><li><a href="/java/hashtable.html" class="sidebar-link">Hashtable</a></li><li><a href="/java/operators.html" class="sidebar-link">Operators</a></li><li><a href="/java/constructors.html" class="sidebar-link">Constructors</a></li><li><a href="/java/object-class-methods-and-constructor.html" class="sidebar-link">Object Class Methods and Constructor</a></li><li><a href="/java/annotations.html" class="sidebar-link">Annotations</a></li><li><a href="/java/immutable-class.html" class="sidebar-link">Immutable Class</a></li><li><a href="/java/immutable-objects.html" class="sidebar-link">Immutable Objects</a></li><li><a href="/java/visibility-controlling-access-to-members-of-a-class.html" class="sidebar-link">Visibility (controlling access to members of a class)</a></li><li><a href="/java/generics.html" class="sidebar-link">Generics</a></li><li><a href="/java/classes-and-objects.html" class="sidebar-link">Classes and Objects</a></li><li><a href="/java/local-inner-class.html" class="sidebar-link">Local Inner Class</a></li><li><a href="/java/nested-and-inner-classes.html" class="sidebar-link">Nested and Inner Classes</a></li><li><a href="/java/the-java-util-objects-class.html" class="sidebar-link">The java.util.Objects Class</a></li><li><a href="/java/default-methods.html" class="sidebar-link">Default Methods</a></li><li><a href="/java/packages.html" class="sidebar-link">Packages</a></li><li><a href="/java/inheritance.html" class="sidebar-link">Inheritance</a></li><li><a href="/java/reference-types.html" class="sidebar-link">Reference Types</a></li><li><a href="/java/console-i-o.html" class="sidebar-link">Console I/O</a></li><li><a href="/java/streams.html" class="sidebar-link">Streams</a></li><li><a href="/java/inputstreams-and-outputstreams.html" class="sidebar-link">InputStreams and OutputStreams</a></li><li><a href="/java/readers-and-writers.html" class="sidebar-link">Readers and Writers</a></li><li><a href="/java/preferences.html" class="sidebar-link">Preferences</a></li><li><a href="/java/collection-factory-methods.html" class="sidebar-link">Collection Factory Methods</a></li><li><a href="/java/alternative-collections.html" class="sidebar-link">Alternative Collections</a></li><li><a href="/java/concurrent-collections.html" class="sidebar-link">Concurrent Collections</a></li><li><a href="/java/choosing-collections.html" class="sidebar-link">Choosing Collections</a></li><li><a href="/java/super-keyword.html" class="sidebar-link">super keyword</a></li><li><a href="/java/serialization.html" class="sidebar-link">Serialization</a></li><li><a href="/java/optional.html" class="sidebar-link">Optional</a></li><li><a href="/java/object-references.html" class="sidebar-link">Object References</a></li><li><a href="/java/exceptions-and-exception-handling.html" class="sidebar-link">Exceptions and exception handling</a></li><li><a href="/java/calendar-and-its-subclasses.html" class="sidebar-link">Calendar and its Subclasses</a></li><li><a href="/java/using-the-static-keyword.html" class="sidebar-link">Using the static keyword</a></li><li><a href="/java/properties-class.html" class="sidebar-link">Properties Class</a></li><li><a href="/java/lambda-expressions.html" class="sidebar-link">Lambda Expressions</a></li><li><a href="/java/basic-control-structures.html" class="sidebar-link">Basic Control Structures</a></li><li><a href="/java/bufferedwriter.html" class="sidebar-link">BufferedWriter</a></li><li><a href="/java/new-file-i-o.html" class="sidebar-link">New File I/O</a></li><li><a href="/java/file-i-o.html" class="sidebar-link">File I/O</a></li><li><a href="/java/scanner.html" class="sidebar-link">Scanner</a></li><li><a href="/java/interfaces.html" class="sidebar-link">Interfaces</a></li><li><a href="/java/regular-expressions.html" class="sidebar-link">Regular Expressions</a></li><li><a href="/java/comparable-and-comparator.html" class="sidebar-link">Comparable and Comparator</a></li><li><a href="/java/java-floating-point-operations.html" class="sidebar-link">Java Floating Point Operations</a></li><li><a href="/java/currency-and-money.html" class="sidebar-link">Currency and Money</a></li><li><a href="/java/object-cloning.html" class="sidebar-link">Object Cloning</a></li><li><a href="/java/recursion.html" class="sidebar-link">Recursion</a></li><li><a href="/java/converting-to-and-from-strings.html" class="sidebar-link">Converting to and from Strings</a></li><li><a href="/java/random-number-generation.html" class="sidebar-link">Random Number Generation</a></li><li><a href="/java/singletons.html" class="sidebar-link">Singletons</a></li><li><a href="/java/autoboxing.html" class="sidebar-link">Autoboxing</a></li><li><a href="/java/2d-graphics-in-java.html" class="sidebar-link">2D Graphics in Java</a></li><li><a href="/java/jaxb.html" class="sidebar-link">JAXB</a></li><li><a href="/java/class-java-reflection.html" class="sidebar-link">Class - Java Reflection</a></li><li><a href="/java/networking.html" class="sidebar-link">Networking</a></li><li><a href="/java/nio-networking.html" class="sidebar-link">NIO - Networking</a></li><li><a href="/java/httpurlconnection.html" class="sidebar-link">HttpURLConnection</a></li><li><a href="/java/jax-ws.html" class="sidebar-link">JAX-WS</a></li><li><a href="/java/nashorn-javascript-engine.html" class="sidebar-link">Nashorn JavaScript engine</a></li><li><a href="/java/java-native-interface.html" class="sidebar-link">Java Native Interface</a></li><li><a href="/java/functional-interfaces.html" class="sidebar-link">Functional Interfaces</a></li><li><a href="/java/fluent-interface.html" class="sidebar-link">Fluent Interface</a></li><li><a href="/java/remote-method-invocation-rmi.html" class="sidebar-link">Remote Method Invocation (RMI)</a></li><li><a href="/java/iterator-and-iterable.html" class="sidebar-link">Iterator and Iterable</a></li><li><a href="/java/reflection-api.html" class="sidebar-link">Reflection API</a></li><li><a href="/java/bytebuffer.html" class="sidebar-link">ByteBuffer</a></li><li><a href="/java/applets.html" class="sidebar-link">Applets</a></li><li><a href="/java/expressions.html" class="sidebar-link">Expressions</a></li><li><a href="/java/json-in-java.html" class="sidebar-link">JSON in Java</a></li><li><a href="/java/xml-parsing-using-the-jaxp-apis.html" class="sidebar-link">XML Parsing using the JAXP APIs</a></li><li><a href="/java/xml-xpath-evaluation.html" class="sidebar-link">XML XPath Evaluation</a></li><li><a href="/java/xom-xml-object-model.html" class="sidebar-link">XOM - XML Object Model</a></li><li><a href="/java/polymorphism.html" class="sidebar-link">Polymorphism</a></li><li><a href="/java/encapsulation.html" class="sidebar-link">Encapsulation</a></li><li><a href="/java/java-agents.html" class="sidebar-link">Java Agents</a></li><li><a href="/java/varargs-variable-argument.html" class="sidebar-link">Varargs (Variable Argument)</a></li><li><a href="/java/logging-java-util-logging.html" class="sidebar-link">Logging (java.util.logging)</a></li><li><a href="/java/log4j-log4j2.html" class="sidebar-link">log4j / log4j2</a></li><li><a href="/java/oracle-official-code-standard.html" class="sidebar-link">Oracle Official Code Standard</a></li><li><a href="/java/character-encoding.html" class="sidebar-link">Character encoding</a></li><li><a href="/java/apache-commons-lang.html" class="sidebar-link">Apache Commons Lang</a></li><li><a href="/java/localization-and-internationalization.html" class="sidebar-link">Localization and Internationalization</a></li><li><a href="/java/parallel-programming-with-fork-join-framework.html" class="sidebar-link">Parallel programming with Fork/Join framework</a></li><li><a href="/java/non-access-modifiers.html" class="sidebar-link">Non-Access Modifiers</a></li><li><a href="/java/process.html" class="sidebar-link">Process</a></li><li><a href="/java/java-native-access.html" class="sidebar-link">Java Native Access</a></li><li><a href="/java/modules.html" class="sidebar-link">Modules</a></li><li><a href="/java/concurrent-programming-threads.html" class="sidebar-link">Concurrent Programming (Threads)</a></li><li><a href="/java/executor-executorservice-and-thread-pools.html" class="sidebar-link">Executor, ExecutorService and Thread pools</a></li><li><a href="/java/threadlocal.html" class="sidebar-link">ThreadLocal</a></li><li><a href="/java/using-threadpoolexecutor-in-multithreaded-applications.html" class="sidebar-link">Using ThreadPoolExecutor in MultiThreaded applications.</a></li><li><a href="/java/common-java-pitfalls.html" class="sidebar-link">Common Java Pitfalls</a></li><li><a href="/java/java-pitfalls-exception-usage.html" class="sidebar-link">Java Pitfalls - Exception usage</a></li><li><a href="/java/java-pitfalls-language-syntax.html" class="sidebar-link">Java Pitfalls - Language syntax</a></li><li><a href="/java/java-pitfalls-threads-and-concurrency.html" class="sidebar-link">Java Pitfalls - Threads and Concurrency</a></li><li><a href="/java/java-pitfalls-nulls-and-nullpointerexception.html" class="sidebar-link">Java Pitfalls - Nulls and NullPointerException</a></li><li><a href="/java/java-pitfalls-performance-issues.html" class="sidebar-link">Java Pitfalls - Performance Issues</a></li><li><a href="/java/serviceloader.html" class="sidebar-link">ServiceLoader</a></li><li><a href="/java/classloaders.html" class="sidebar-link">Classloaders</a></li><li><a href="/java/creating-images-programmatically.html" class="sidebar-link">Creating Images Programmatically</a></li><li><a href="/java/atomic-types.html" class="sidebar-link">Atomic Types</a></li><li><a href="/java/rsa-encryption.html" class="sidebar-link">RSA Encryption</a></li><li><a href="/java/secure-objects.html" class="sidebar-link">Secure objects</a></li><li><a href="/java/security-cryptography.html" class="sidebar-link">Security & Cryptography</a></li><li><a href="/java/securitymanager.html" class="sidebar-link">SecurityManager</a></li><li><a href="/java/jndi.html" class="sidebar-link">JNDI</a></li><li><a href="/java/sun-misc-unsafe.html" class="sidebar-link">sun.misc.Unsafe</a></li><li><a href="/java/java-memory-model.html" class="sidebar-link">Java Memory Model</a></li><li><a href="/java/java-deployment.html" aria-current="page" class="active sidebar-link">Java deployment</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/java/java-deployment.html#making-an-executable-jar-from-the-command-line" class="sidebar-link">Making an executable JAR from the command line</a></li><li class="sidebar-sub-header"><a href="/java/java-deployment.html#creating-jar-war-and-ear-files" class="sidebar-link">Creating JAR, WAR and EAR files</a></li><li class="sidebar-sub-header"><a href="/java/java-deployment.html#introduction-to-java-web-start" class="sidebar-link">Introduction to Java Web Start</a></li><li class="sidebar-sub-header"><a href="/java/java-deployment.html#creating-an-uberjar-for-an-application-and-its-dependencies" class="sidebar-link">Creating an UberJAR for an application and its dependencies</a></li></ul></li><li><a href="/java/java-plugin-system-implementations.html" class="sidebar-link">Java plugin system implementations</a></li><li><a href="/java/javabean.html" class="sidebar-link">JavaBean</a></li><li><a href="/java/java-se-7-features.html" class="sidebar-link">Java SE 7 Features</a></li><li><a href="/java/java-se-8-features.html" class="sidebar-link">Java SE 8 Features</a></li><li><a href="/java/dynamic-method-dispatch.html" class="sidebar-link">Dynamic Method Dispatch</a></li><li><a href="/java/generating-java-code.html" class="sidebar-link">Generating Java Code</a></li><li><a href="/java/jshell.html" class="sidebar-link">JShell</a></li><li><a href="/java/stack-walking-api.html" class="sidebar-link">Stack-Walking API</a></li><li><a href="/java/sockets.html" class="sidebar-link">Sockets</a></li><li><a href="/java/java-sockets.html" class="sidebar-link">Java Sockets</a></li><li><a href="/java/ftp-file-transfer-protocol.html" class="sidebar-link">FTP (File Transfer Protocol)</a></li><li><a href="/java/using-other-scripting-languages-in-java.html" class="sidebar-link">Using Other Scripting Languages in Java</a></li><li><a href="/java/c-comparison.html" class="sidebar-link">C++ Comparison</a></li><li><a href="/java/audio.html" class="sidebar-link">Audio</a></li><li><a href="/java/java-print-service.html" class="sidebar-link">Java Print Service</a></li><li><a href="/java/completablefuture.html" class="sidebar-link">CompletableFuture</a></li><li><a href="/java/runtime-commands.html" class="sidebar-link">Runtime Commands</a></li><li><a href="/java/unit-testing.html" class="sidebar-link">Unit Testing</a></li><li><a href="/java/asserting.html" class="sidebar-link">Asserting</a></li><li><a href="/java/multi-release-jar-files.html" class="sidebar-link">Multi-Release JAR Files</a></li><li><a href="/java/just-in-time-jit-compiler.html" class="sidebar-link">Just in Time (JIT) compiler</a></li><li><a href="/java/bytecode-modification.html" class="sidebar-link">Bytecode Modification</a></li><li><a href="/java/disassembling-and-decompiling.html" class="sidebar-link">Disassembling and Decompiling</a></li><li><a href="/java/jmx.html" class="sidebar-link">JMX</a></li><li><a href="/java/java-virtual-machine-jvm.html" class="sidebar-link">Java Virtual Machine (JVM)</a></li><li><a href="/java/xjc.html" class="sidebar-link">XJC</a></li><li><a href="/java/jvm-flags.html" class="sidebar-link">JVM Flags</a></li><li><a href="/java/jvm-tool-interface.html" class="sidebar-link">JVM Tool Interface</a></li><li><a href="/java/java-memory-management.html" class="sidebar-link">Java Memory Management</a></li><li><a href="/java/java-performance-tuning.html" class="sidebar-link">Java Performance Tuning</a></li><li><a href="/java/benchmarks.html" class="sidebar-link">Benchmarks</a></li><li><a href="/java/fileupload-to-aws.html" class="sidebar-link">FileUpload to AWS</a></li><li><a href="/java/appdynamics-and-tibco-businessworks-instrumentation-for-easy-integration.html" class="sidebar-link">AppDynamics and TIBCO BusinessWorks Instrumentation for Easy Integration</a></li><li><a href="/java/the-classpath.html" class="sidebar-link">The Classpath</a></li><li><a href="/java/resources-on-classpath.html" class="sidebar-link">Resources (on classpath)</a></li><li><a href="/java/contributors.html" class="sidebar-link">The Contributors</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="java-deployment"><a href="#java-deployment" class="header-anchor">#</a> Java deployment</h1> <p>There are a variety of technologies for "packaging" Java applications, webapps and so forth, for deployment to the platform on which they will run. They range from simple library or executable <code>JAR</code> files, <code>WAR</code> and <code>EAR</code> files, through to installers and self-contained executables.</p> <h2 id="making-an-executable-jar-from-the-command-line"><a href="#making-an-executable-jar-from-the-command-line" class="header-anchor">#</a> Making an executable JAR from the command line</h2> <p>To make a jar, you need one or more class files. This should have a main method if it is to be run by a double click.</p> <p>For this example, we will use:</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token keyword">import</span> <span class="token namespace">javax<span class="token punctuation">.</span>swing<span class="token punctuation">.</span></span><span class="token operator">*</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>awt<span class="token punctuation">.</span></span><span class="token class-name">Container</span><span class="token punctuation">;</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HelloWorld</span> <span class="token punctuation">{</span>
<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token class-name">JFrame</span> f <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JFrame</span><span class="token punctuation">(</span><span class="token string">"Hello, World"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">JLabel</span> label <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JLabel</span><span class="token punctuation">(</span><span class="token string">"Hello, World"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">Container</span> cont <span class="token operator">=</span> f<span class="token punctuation">.</span><span class="token function">getContentPane</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
cont<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>label<span class="token punctuation">)</span><span class="token punctuation">;</span>
f<span class="token punctuation">.</span><span class="token function">setSize</span><span class="token punctuation">(</span><span class="token number">400</span><span class="token punctuation">,</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
f<span class="token punctuation">.</span><span class="token function">setVisible</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
f<span class="token punctuation">.</span><span class="token function">setDefaultCloseOperation</span><span class="token punctuation">(</span><span class="token class-name">JFrame</span><span class="token punctuation">.</span>EXIT_ON_CLOSE<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><p>It has been named HelloWorld.java</p> <p>Next, we want to compile this program.</p> <p>You may use any program you want to do this. To run from the command line,
see the documentation <a href="http://stackoverflow.com/documentation/java/84/compile-and-run-your-first-java-program#t=201608051426147769964" target="_blank" rel="noopener noreferrer">on compiling and running your first java program.<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>Once you have HelloWorld.class, make a new folder and call it whatever you want.</p> <p>Make another file called manifest.txt and paste into it</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token class-name">Main</span><span class="token operator">-</span><span class="token class-name">Class</span><span class="token operator">:</span> <span class="token class-name">HelloWorld</span>
<span class="token class-name">Class</span><span class="token operator">-</span><span class="token class-name">Path</span><span class="token operator">:</span> <span class="token class-name">HelloWorld</span><span class="token punctuation">.</span>jar
</code></pre></div><p>Put it in the same folder with HelloWorld.class <br>
Use the command line to make your current directory (<code>cd C:\Your\Folder\Path\Here</code> on windows) your folder.</p> <p>Use Terminal and change directory to the directory (<code>cd /Users/user/Documents/Java/jarfolder</code> on Mac) your folder</p> <p>When that is done, type in <code>jar -cvfm HelloWorld.jar manifest.txt HelloWorld.class</code> and press enter. This makes a jar file (in the folder with your manifest and HelloWorld.class) using the .class files specified and named HelloWorld.jar. See the Syntax section for information about the options (like -m and -v). <br>
After these steps, go to your directory with the manifest file and you should find HelloWorld.jar <br>
Clicking on it should display <code>Hello, World</code> in a text box.</p> <h2 id="creating-jar-war-and-ear-files"><a href="#creating-jar-war-and-ear-files" class="header-anchor">#</a> Creating JAR, WAR and EAR files</h2> <p>The JAR, WAR and EAR files types are fundamentally ZIP files with a "manifest" file and (for WAR and EAR files) a particular internal directory / file structure.</p> <p>The recommended way to create these files is to use a Java-specific build tool which "understands" the requirements for the respective file types. If you don't use a build tool, then IDE "export" is the next option to try.</p> <p>(<strong>Editorial note: the descriptions of how to create these files are best placed in the documentation for the respective tools. Put them there. Please show some self-restraint and DON'T shoe-horn them into this example!</strong>)</p> <h3 id="creating-jar-and-war-files-using-maven"><a href="#creating-jar-and-war-files-using-maven" class="header-anchor">#</a> Creating JAR and WAR files using Maven</h3> <p>Creating a JAR or WAR using Maven is simply a matter of putting the correct <code><packaging></code> element into the POM file; e,g,</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token generics"><span class="token punctuation"><</span>packaging<span class="token punctuation">></span></span>jar<span class="token operator"><</span><span class="token operator">/</span>packaging<span class="token operator">></span>
</code></pre></div><p>or</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token generics"><span class="token punctuation"><</span>packaging<span class="token punctuation">></span></span>war<span class="token operator"><</span><span class="token operator">/</span>packaging<span class="token operator">></span>
</code></pre></div><p>For more details. Maven can be configured to create "executable" JAR files by adding the requisite information about the entry-point class and external dependencies as plugin properties for the maven jar plugin. There is even a plugin for creating "uberJAR" files that combine an application and its dependencies into a single JAR file.</p> <p>Please refer to the Maven documentation ( <a href="http://stackoverflow.com/documentation/maven/topics" target="_blank" rel="noopener noreferrer">http://stackoverflow.com/documentation/maven/topics<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> )for more information.</p> <h3 id="creating-jar-war-and-ear-files-using-ant"><a href="#creating-jar-war-and-ear-files-using-ant" class="header-anchor">#</a> Creating JAR, WAR and EAR files using Ant</h3> <p>The Ant build tool has separate "tasks" for building JAR, WAR and EAR. Please refer to the Ant documentation ( <a href="http://stackoverflow.com/documentation/ant/topics" target="_blank" rel="noopener noreferrer">http://stackoverflow.com/documentation/ant/topics<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> ) for more information.</p> <h3 id="creating-jar-war-and-ear-files-using-an-ide"><a href="#creating-jar-war-and-ear-files-using-an-ide" class="header-anchor">#</a> Creating JAR, WAR and EAR files using an IDE</h3> <p>The three most popular Java IDEs all have built-in support for creating deployment files. The functionality is often described as "exporting".</p> <ul><li>Eclipse - <a href="http://stackoverflow.com/documentation/eclipse/topics" target="_blank" rel="noopener noreferrer">http://stackoverflow.com/documentation/eclipse/topics<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li>NetBeans - <a href="http://stackoverflow.com/documentation/netbeans/topics" target="_blank" rel="noopener noreferrer">http://stackoverflow.com/documentation/netbeans/topics<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li>Intellij-IDEA - <a href="http://stackoverflow.com/documentation/intellij-idea/4807/exporting" target="_blank" rel="noopener noreferrer">Exporting<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <h3 id="creating-jar-war-and-ear-files-using-the-jar-command"><a href="#creating-jar-war-and-ear-files-using-the-jar-command" class="header-anchor">#</a> Creating JAR, WAR and EAR files using the <code>jar</code> command.</h3> <p>It is also possible to create these files "by hand" using the <code>jar</code> command. It is simply a matter of assembling a file tree with the correct component files in the correct place, creating a manifest file, and running <code>jar</code> to create the JAR file.</p> <p>Please refer to the <code>jar</code> command Topic ( <a href="http://stackoverflow.com/documentation/java/5247/creating-and-modifying-jar-files" target="_blank" rel="noopener noreferrer">Creating and modifying JAR files<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> ) for more information</p> <h2 id="introduction-to-java-web-start"><a href="#introduction-to-java-web-start" class="header-anchor">#</a> Introduction to Java Web Start</h2> <p>The Oracle Java Tutorials summarize <a href="https://docs.oracle.com/javase/tutorial/deployment/webstart/" target="_blank" rel="noopener noreferrer">Web Start<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> as follows:</p> <blockquote></blockquote> <p>Java Web Start software provides the power to launch full-featured applications with a single click. Users can download and launch applications, such as a complete spreadsheet program or an Internet chat client, without going through lengthy installation procedures.</p> <p>Other advantages of Java Web Start are support for signed code and explicit declaration of platform dependencies, and support for code caching and deployment of application updates.</p> <p>Java Web Start is also referred to as JavaWS and JAWS. The primary sources of information are:</p> <ul><li><a href="https://docs.oracle.com/javase/tutorial/deployment/webstart/" target="_blank" rel="noopener noreferrer">The Java Tutorials - Lesson: Java Web Start<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://www.oracle.com/technetwork/java/javase/javawebstart/index.html" target="_blank" rel="noopener noreferrer">Java Web Start Guide<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://www.oracle.com/technetwork/java/javase/javawebstart/index.html" target="_blank" rel="noopener noreferrer">Java Web Start FAQ<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://www.oracle.com/technetwork/java/javase/javawebstart/index.html" target="_blank" rel="noopener noreferrer">JNLP Specification<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://www.oracle.com/technetwork/java/javase/javawebstart/index.html" target="_blank" rel="noopener noreferrer"><code>javax.jnlp</code> API Documentation<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://www.oracle.com/technetwork/java/javase/javawebstart/index.html" target="_blank" rel="noopener noreferrer">Java Web Start Developers Site<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <h3 id="prerequisites"><a href="#prerequisites" class="header-anchor">#</a> Prerequisites</h3> <p>At a high level, Web Start works by distributing Java applications packed as JAR files from a remote webserver. The prerequisites are:</p> <li>
A pre-existing Java installation (JRE or JDK) on the target machine where the application is to run. Java 1.2.2 or higher is required:
<ul>
- From Java 5.0 onwards, Web Start support is included in the JRE / JDK.
- For earlier releases, Web Start support is installed separately.
- The Web Start infrastructure includes some Javascript that can be included in a web page to assist the user to install the necessary software.
<p>The webserver that hosts the software must be accessible to the target machine.</p> <p>If the user is going to launch a Web Start application using a link in a web page, then:</p> <ul><li>they need a compatible web browser, and</li> <li>for modern (secure) browsers, they need to be told how to tell the browser to allow Java to run ... without compromising web browser security.</li></ul> <h3 id="an-example-jnlp-file"><a href="#an-example-jnlp-file" class="header-anchor">#</a> An example JNLP file</h3> <p>The following example is intended to illustrate the basic functionality of JNLP.</p> <div class="language-java extra-class"><pre class="language-java"><code><span class="token operator"><</span><span class="token operator">?</span>xml version<span class="token operator">=</span><span class="token string">"1.0"</span> encoding<span class="token operator">=</span><span class="token string">"UTF-8"</span><span class="token operator">?</span><span class="token operator">></span>
<span class="token operator"><</span>jnlp spec<span class="token operator">=</span><span class="token string">"1.0+"</span> codebase<span class="token operator">=</span><span class="token string">"https://www.example.com/demo"</span>
href<span class="token operator">=</span><span class="token string">"demo_webstart.jnlp"</span><span class="token operator">></span>
<span class="token generics"><span class="token punctuation"><</span>information<span class="token punctuation">></span></span>
<span class="token generics"><span class="token punctuation"><</span>title<span class="token punctuation">></span></span><span class="token class-name">Demo</span><span class="token operator"><</span><span class="token operator">/</span>title<span class="token operator">></span>
<span class="token generics"><span class="token punctuation"><</span>vendor<span class="token punctuation">></span></span><span class="token class-name">The</span> <span class="token class-name">Example</span><span class="token punctuation">.</span>com <span class="token class-name">Team</span><span class="token operator"><</span><span class="token operator">/</span>vendor<span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">/</span>information<span class="token operator">></span>
<span class="token generics"><span class="token punctuation"><</span>resources<span class="token punctuation">></span></span>
<span class="token operator"><</span><span class="token operator">!</span><span class="token operator">--</span> <span class="token class-name">Application</span> <span class="token class-name">Resources</span> <span class="token operator">--</span><span class="token operator">></span>
<span class="token operator"><</span>j2se version<span class="token operator">=</span><span class="token string">"1.7+"</span> href<span class="token operator">=</span><span class="token string">"http://java.sun.com/products/autodl/j2se"</span><span class="token operator">/</span><span class="token operator">></span>
<span class="token operator"><</span>jar href<span class="token operator">=</span><span class="token string">"Demo.jar"</span> main<span class="token operator">=</span><span class="token string">"true"</span><span class="token operator">/</span><span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">/</span>resources<span class="token operator">></span>
<span class="token operator"><</span>application<span class="token operator">-</span>desc
name<span class="token operator">=</span><span class="token string">"Demo Application"</span>
main<span class="token operator">-</span><span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"com.example.jwsdemo.Main"</span>
width<span class="token operator">=</span><span class="token string">"300"</span>
height<span class="token operator">=</span><span class="token string">"300"</span><span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">/</span>application<span class="token operator">-</span>desc<span class="token operator">></span>
<span class="token operator"><</span>update check<span class="token operator">=</span><span class="token string">"background"</span><span class="token operator">/</span><span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">/</span>jnlp<span class="token operator">></span>
</code></pre></div><p>As you can see, a JNLP file XML-based, and the information is all contained in the <code><jnlp></code> element.</p> <ul><li>The <code>spec</code> attribute gives the version of the JNPL spec that this file conforms to.</li> <li>The <code>codebase</code> attribute gives the base URL for resolving relative <code>href</code> URLs in the rest of the file.</li> <li>The <code>href</code> attribute gives the definitive URL for this JNLP file.</li> <li>The <code><information></code> element contains metadata the application including its title, authors, description and help website.</li> <li>The <code><resources></code> element describes the dependencies for the application including the required Java version, OS platform and JAR files.</li> <li>The <code><application-desc></code> (or <code><applet-desc></code>) element provides information needed to launch the application.</li></ul> <h3 id="setting-up-the-web-server"><a href="#setting-up-the-web-server" class="header-anchor">#</a> Setting up the web server</h3> <p>The webserver must be configured to use <code>application/x-java-jnlp-file</code> as the MIMEtype for <code>.jnlp</code> files.</p> <p>The JNLP file and the application's JAR files must be installed on the webserver so that they are available using the URLs indicated by the JNLP file.</p> <h3 id="enabling-launch-via-a-web-page"><a href="#enabling-launch-via-a-web-page" class="header-anchor">#</a> Enabling launch via a web page</h3> <p>If the application is to be launched via a web link, the page that contains the link must be created on the webserver.</p> <li>
If you can assume that Java Web Start is already installed on the user's machine, then the web page simply needs to contain a link for launching the application. For example.
<div class="language-java extra-class"><pre class="language-java"><code><span class="token operator"><</span>a href<span class="token operator">=</span><span class="token string">"https://www.example.com/demo_webstart.jnlp"</span><span class="token operator">></span><span class="token class-name">Launch</span> the application<span class="token operator"><</span><span class="token operator">/</span>a<span class="token operator">></span>
</code></pre></div></li> <li>
Otherwise, the page should also include some scripting to detect the kind of browser the user is using and request to download and install the required version of Java.
</li> <p><strong>NOTE:</strong> It is a bad idea to encourage users to encourage to install Java this way, or even to enable Java in their web browsers so that JNLP web page launch will work.</p> <h3 id="launching-web-start-applications-from-the-command-line"><a href="#launching-web-start-applications-from-the-command-line" class="header-anchor">#</a> Launching Web Start applications from the command line</h3> <p>The instructions for launching an Web Start application from the command line are simple. Assuming that the user has a Java 5.0 JRE or JDK installed, the simply need to run this:</p> <div class="language-java extra-class"><pre class="language-java"><code>$ javaws <span class="token generics"><span class="token punctuation"><</span>url<span class="token punctuation">></span></span>
</code></pre></div><p>where <code><url></code> is the URL for the JNLP file on the remote server.</p> <h2 id="creating-an-uberjar-for-an-application-and-its-dependencies"><a href="#creating-an-uberjar-for-an-application-and-its-dependencies" class="header-anchor">#</a> Creating an UberJAR for an application and its dependencies</h2> <p>A common requirement for a Java application is that can be deployed by copying a single file. For simple applications that depend only on the standard Java SE class libraries, this requirement is satisfied by creating a JAR file containing all of the (compiled) application classes.</p> <p>Things are not so straightforward if the application depends on third-party libraries. If you simply put dependency JAR files inside an application JAR, the standard Java class loader will not be able to find the library classes, and your application will not start. Instead, you need to create a single JAR file that contains the application classes and associated resources together with the dependency classes and resources. These need to be organized as a single namespace for the classloader to search.</p> <p>The such a JAR file is often referred to as an UberJAR.</p> <h3 id="creating-an-uberjar-using-the-jar-command"><a href="#creating-an-uberjar-using-the-jar-command" class="header-anchor">#</a> Creating an UberJAR using the "jar" command</h3> <p>The procedure for creating an UberJAR is straight-forward. (I will use Linux commands for simplicity. The commands should be identical for Mac OS, and similar for Windows.)</p> <li>
Create a temporary directory, and change directory to it.
<div class="language-java extra-class"><pre class="language-java"><code>$ mkdir tempDir
$ cd tempDir
</code></pre></div></li> <li>
For each dependent JAR file, **in the reverse order** that they need to appear on the application's classpath, used the `jar` command to unpack the JAR into the temporary directory.
<div class="language-java extra-class"><pre class="language-java"><code>$ jar <span class="token operator">-</span>xf <span class="token operator"><</span>path<span class="token operator">/</span><span class="token keyword">to</span><span class="token operator">/</span>file<span class="token punctuation">.</span>jar<span class="token operator">></span>
</code></pre></div><p>Doing this for multiple JAR files will <strong>overlay</strong> contents of the JARs.
</p></li> <li>
Copy the application classes from the build tree into the temporary directory<p></p> <div class="language-java extra-class"><pre class="language-java"><code>$ cp <span class="token operator">-</span>r path<span class="token operator">/</span><span class="token keyword">to</span><span class="token operator">/</span>classes <span class="token punctuation">.</span>
</code></pre></div></li> <li>
Create the UberJAR from the contents of the temporary directory:
<div class="language-java extra-class"><pre class="language-java"><code>$ jar <span class="token operator">-</span>cf <span class="token punctuation">.</span><span class="token punctuation">.</span>/myApplication<span class="token punctuation">.</span>jar
</code></pre></div><p>If you are creating an executable JAR file, include an appropriate MANIFEST.MF as described here.
</p></li><p></p> <h3 id="creating-an-uberjar-using-maven"><a href="#creating-an-uberjar-using-maven" class="header-anchor">#</a> Creating an UberJAR using Maven</h3> <p>If your project is built using Maven, you can get it to create an UberJAR using either the "maven-assembly" or "maven-shade" plugins. See the <a href="http://stackoverflow.com/documentation/maven/2308/maven-assembly-plugin#t=201701150039251624937" target="_blank" rel="noopener noreferrer">Maven Assembly<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> topic (in the <a href="http://stackoverflow.com/documentation/maven/topics" target="_blank" rel="noopener noreferrer">Maven<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> documentation) for details.</p> <h3 id="the-advantages-and-drawbacks-of-uberjars"><a href="#the-advantages-and-drawbacks-of-uberjars" class="header-anchor">#</a> The advantages and drawbacks of UberJARs</h3> <p>Some of advantages of UberJARs are self-evident:</p> <ul><li>An UberJAR is easy to distribute.</li> <li>You cannot break the library dependencies for an UberJAR, since the libraries are self-contained.</li></ul> <p>In addition, if you use an appropriate tooling to create the UberJAR, you will have the option of excluding library classes that are not used from the JAR file. However, that this is typically done by static analysis of the classes. If your application uses reflection, annotation processing and similar techniques, you need to be careful that classes are not excluded incorrectly.</p> <p>UberJARs also have some disadvantages:</p> <ul><li>If you have lots of UberJARs with the same dependencies, then each one will contain a copy of the dependencies.</li> <li>Some open source libraries have licenses which <strong>may</strong> preclude <sup>1</sup> their use in an UberJAR.</li></ul> <p><sup>1 - Some open source library licenses allow you to use the library only of the end-user is able to replace one version of the library with another. UberJARs can make replacement of version dependencies difficult.</sup></p> <h4 id="remarks"><a href="#remarks" class="header-anchor">#</a> Remarks</h4> <p>At the most fundamental level, a Java program can be deployed by copying a compiled class (i.e. a ".class" file) or a directory tree containing compiled classes. However Java is normally deployed in one of the following ways:</p> <li>
By copying a JAR file or collection of JAR files to the system where they will be executed; e.g. using `javac`.
</li> <li>
By copying or uploading a WAR, EAR or similar file to a "servlet container" or "application server".
</li> <li>
By running some kind of application installer that automates the above. The installer might also install an embedded JRE.
</li> <li>
By putting the JAR files for the application onto a web server to allow them to be launched using Java WebStart.
</li> <p>The Creating JAR, WAR and EAR files example summarizes the different ways to create these files.</p> <p>There are numerous open source and commercial "installer generator" and
"EXE generator" tools for Java. Similarly, there are tools for obfuscating Java class files (to make reverse engineering harder) and for adding runtime license checking. These are all out of scope for the "Java Programming Language" documentation.</p></ul></li></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/devtut/generate/edit/master/docs/java/java-deployment.md" target="_blank" rel="noopener noreferrer">Edit this page on GitHub</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
←
<a href="/java/java-memory-model.html" class="prev">
Java Memory Model
</a></span> <span class="next"><a href="/java/java-plugin-system-implementations.html">
Java plugin system implementations
</a>
→
</span></p></div> </main></div><div class="global-ui"><!----></div></div>
<script src="/assets/js/app.1779e102.js" defer></script><script src="/assets/js/3.2cfa8016.js" defer></script><script src="/assets/js/1588.04d50216.js" defer></script>
</body>
</html>