问题描述
我可以使用JWS启动吗? One-JAR提供了定制的类加载器,该类加载器知道如何从存档中的jar中加载类和资源,而在JWS中,我们需要指定资源中使用的每个JAR。
Can I supposed to launch One-Jar using JWS? One-JAR provides custom classloader that knows how to load classes and resources from a jars inside an archive whereas in JWS we need to specify each JAR that is being used in resources.
如果我尝试启动-
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
<information>
<title>Application</title>
<vendor>ABC</vendor>
</information>
<resources>
<!-- Application Resources -->
<j2se version="1.5+"
href="http://java.sun.com/products/autodl/j2se"/>
<jar href="Application.jar" main="true" download="eager" />
</resources>
<application-desc main-class="com.simontuffs.onejar.Boot">
</application-desc>
<update check="background"/>
<security>
<all-permissions/>
</security>
</jnlp>
我的一个JAR的应用JAR包含-
My Application JAR that is One-JAR contains -
com\simontuffs\onejar\<contains complied classes> like JarClassLoader$1.class etc
lib/<contains all jar>
OneJar.class
main/<my application's jar>
META-INF\MANIFEST.MF\ <contains >
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: One-Jar 0.96 Ant taskdef
Main-Class: com.simontuffs.onejar.Boot
One-Jar-Main-Class: com.application.main.Entry
Name: com/simontuffs/onejar/Boot$3.class
SHA1-Digest: +LPrezs+UEFcE3J7QvumcAEO8Z0=
Name: OneJar.class
SHA1-Digest: 28pzzJWqEpLk1xFwJ/jsAav8LyI=
Name: lib/commons-io-1.4.jar
SHA1-Digest: qHYtB+ds/eI5Ulel2ke6fB29Pc4=
等。等等。
如何在资源中指定这些 com / simontuffs / onejar / Boot $ 3.class 路径?
How to specify these com/simontuffs/onejar/Boot$3.class paths in resource ?
推荐答案
支持One-Jar之类的工具的部分问题是,在Jar中加载Jar需要自定义类加载器。默认情况下,JWS将使用通常的JRE类加载器-不支持它。
Part of the problem of supporting tools like One-Jar is that loading Jars within Jars requires a custom class-loader. By default JWS will use the usual JRE class-loaders - which do not support it.
有两种可能的解决方法(我知道)
There are two possible ways that you might get around that (that I know of).
获取One-Jar使用的定制加载器的实例,并将其设置为上下文类加载器。这将需要一个受信任的应用程序。但是,我给您的印象是您的应用程序。
Get an instance of the custom loader used by One-Jar and set it as the context class-loader. This would require a trusted app., but I get the impression that your app. is trusted.
我不知道One-Jar API是否为您自己的应用程序提供了此加载程序。
I have no idea if the One-Jar API provides this loader for your own app.'s use.
来自 ..
one-jar.jar.names
one-jar.jar.names
-
true
:保留记录的课程 -
false
:将记录的类展平到一个目录中。
重复项被忽略(第一次获胜)
true
: Recorded classes are kept in directories corresponding to their jar names.false
: Recorded classes are flattened into a single directory. Duplicates are ignored (first wins)
第二个选项听起来像是一个标准的'胖子。这应该与JWS使用的常规(默认)类加载器一起工作。
The 2 option sounds like a standard 'fat jar'. That should work with the conventional (default) class-loader used by JWS.
这篇关于JWS是否支持启动One-Jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!