JWS 是否支持启动 One-Jar [英] does JWS support to launch One-Jar

查看:24
本文介绍了JWS 是否支持启动 One-Jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 JWS 启动 One-Jar 吗?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.

如果我尝试启动 One-Jar,我应该在 JNLP 中指定什么 - >

What I supposed to specify in JNLP if I am trying to launch One-Jar -

<?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 是 One-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 等工具的部分问题是在 Jars 中加载 Jars 需要自定义类加载器.默认情况下,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.

来自 选项和 VM 属性..

one-jar.jar.names

  • true:记录的类保存在对应于它们的 jar 名称的目录中.
  • 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)

2nd 选项听起来像一个标准的胖罐".这应该适用于 JWS 使用的传统(默认)类加载器.

The 2nd option sounds like a standard 'fat jar'. That should work with the conventional (default) class-loader used by JWS.

这篇关于JWS 是否支持启动 One-Jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆