我需要添加-Djava.security.policy=myPolicyFile以便我的 RMI jar 能够工作。或者还有其他方法可以运行吗?
我需要从 jar 可执行文件中的 java 应用程序读取外部 XML 文件。
如果我从控制台 (java -jar package.jar) 吃午饭它工作正常,但如果我通过双击 (Java Platform SE 二进制文件) 吃午饭它不起作用。
我有相对路径的这个问题。使用绝对路径,它可以双向工作。
我使用 Java Swings 制作了一个小型应用程序,然后使用 Netbeans 中的“清理和构建”选项创建了该项目的 jar 文件。然后,我使用软件“Launch4j”将该 .jar 文件转换为 .exe 文件,它在我的笔记本电脑上完美运行。但是,当我尝试在其他笔记本电脑上运行该 exe 文件时。它显示错误:无法找到 Class NewJframe.firstfile。(我也在另一台笔记本电脑上使用 MySql 连接创建了数据库)。
请帮助我澄清为什么我会收到此错误。另外,我想知道在其他计算机上运行我从 .jar 文件创建的 .exe 文件有哪些要求?
在尝试从运行 Java 1.8.0_121 的基于 JavaFX Maven 的项目创建可执行 jar 时,我使用了以下命令:mvn clean assembly:single。在此过程中,会打印以下警告:
[WARNING] Cannot include project artifact: groupid:artifactid:jar:1.0-SNAPSHOT; it doesn't have an associated file or directory.
Run Code Online (Sandbox Code Playgroud)
生成的 jar 文件已构建,但无法执行。运行时java -jar product.jar,打印出以下错误:
Error: Could not find or load main class groupid.artifactid.MainClass
Run Code Online (Sandbox Code Playgroud)
pom 文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupid</groupId>
<artifactId>artifactid</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<organization>
<name>org</name>
</organization>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<finalName>product</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>groupid.artifactid.MainClass</mainClass>
</manifest>
</archive>
<finalName>product</finalName> …Run Code Online (Sandbox Code Playgroud) 我知道如何将“jar”转换为 Windows 可执行文件(.exe)。但我想知道如何将“jar”转换为 Linux 可执行文件(.?)。我已经搜索过谷歌,但没有得到我想要的确切答案,请帮助做到这一点。
我在一个系统上使用IntelliJIDE armx64 linux-based,我正在处理一个非 Maven java 项目,该项目有很多链接到它的模块(依赖项)。当从 IDE 运行我的项目时,一切正常,但是当将其构建为可运行的 jar 文件并尝试使用从终端运行该 jar 时java -jar myjar.jar,我收到以下错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
at java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:977)
at sun.misc.Resource.cachedInputStream(Resource.java:77)
at sun.misc.Resource.getByteBuffer(Resource.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:454)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用NetBeans 11.0生成(.JAR)文件,我遵循了一些答案,例如如何在 Netbeans 中创建 Jar 文件,但我没有在 Build 下找到 Packaging,我也尝试Clean & Build Project但是我找不到文件夹。/dist
谁能帮我
日志 :
Scanning for projects...
------------------------------------------------------------------------
Building FlickerURLMaker 1.0-SNAPSHOT
------------------------------------------------------------------------
--- maven-clean-plugin:2.5:clean (default-clean) @ FlickerURLMaker ---
Deleting C:\Users\USER\Documents\NetBeansProjects\FlickerURLMaker\target
--- maven-resources-plugin:2.6:resources (default-resources) @ FlickerURLMaker ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\Users\USER\Documents\NetBeansProjects\FlickerURLMaker\src\main\resources
--- maven-compiler-plugin:3.1:compile (default-compile) @ FlickerURLMaker ---
Changes detected - recompiling the module!
Compiling 2 source files to C:\Users\USER\Documents\NetBeansProjects\FlickerURLMaker\target\classes
--- maven-resources-plugin:2.6:testResources (default-testResources) @ …Run Code Online (Sandbox Code Playgroud) 目前我正在使用微服务和 Docker 容器进行测试。在我上次尝试使用 Micronaut-Server 期间,我发现本地启动 (cmd) 和使用 Docker 启动的启动时间之间存在差异。但令我好奇的是,Container 的速度要快得多。
我正在使用 Gradle 创建一个可运行的 jar(更准确地说是 Shadowjar - 不确定确切的区别是什么)。然后我使用该 jar 文件构建一个 Docker 映像。两者的启动命令是相同的(参见下面的 Dockerfile):
java -jar micronaut.jar
在我寻找原因的过程中,我发现这个问题也与 Docker-Container 的性能有关,但结论更多的是,容器应该稍微慢一点,而不是更快。
FROM adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim
COPY build/libs/*.jar micronaut.jar
EXPOSE 8080
CMD java -jar micronaut.jar
Run Code Online (Sandbox Code Playgroud)
和泊坞窗命令:
docker run -p 9999:9999 -it --name dokuserver pge/dokuserver:0.1
我预计容器的启动时间会相同,但速度会慢一些,但实际上时间是这样的。
我尝试了好几次,但结果总是几乎相同。
我正在使用 DockerDesktop (Docker 19.03.1)、IntelliJ 和 Gradle (5.5.1) 的 Win10 PC 工作,并使用 IntelliJ-Terminal 和 windows-cmd 进行本地启动。
我不是 Docker 或更接近硬件的事情方面的专家,所以我找不到这种速度差异的答案。所以我问你:
什么可能导致这种情况?
使用javafx创建了一个非常简单的GUI,试图测试创建javafx exe的工作原理,从Eclipse中提取了一个可运行的jar文件,但除非我使用cmd并添加VM参数--module-path“”--add,否则该文件不会运行-modules=javafx.controls,javafx.fxml,所以我尝试使用 launch4j 从该 jar 文件制作一个 exe,它会将我重定向到 java.com/downloads,所以我现在将 JRE bin 和 lib 文件夹与 exe 文件一起嵌入根本不运行。我错过了什么或者做错了什么吗?
我有一个可执行文件 jar,可以使用java -jar app.jar运行,但SDK 为 326MB。这是很多。
jlink 可以创建JRE,但我无法使用jlink,因为我有一个非模块化应用程序。
您能告诉我如何创建 JRE 吗?
executable-jar ×10
java ×9
jar ×6
javafx ×2
maven ×2
docker ×1
exe ×1
java-8 ×1
jlink ×1
launch4j ×1
linux ×1
netbeans ×1
netbeans-11 ×1
performance ×1
swing ×1