java.lang.IllegalArgumentException : plexus.container.default:无效的模块名称: 'default'不是Java标识符

标签 java windows eclipse javafx

当我尝试使用脚本 bash 启动我的 jar 时遇到这个问题:

完整问题:

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\aposk\Desktop\Twitter_App_Win_Version\app\ressources\lib\plexus-container-default-1.0-alpha-9-stable-1.jar

Caused by: java.lang.IllegalArgumentException: plexus.container.default: Invalid module name: 'default' is not a Java identifier

脚本bash

@echo off

::apt-get install openjfx
SET JAVA_HOME=C:\Users\aposk\Desktop\Twitter_App_Win_Version\jdk-13.0.1
SET PATH=%JAVA_HOME%\bin;%PATH%
java -version

java -jar --module-path "C:\Users\aposk\Desktop\Twitter_App_Win_Version\app\ressources\lib" --add-modules=javafx.controls,javafx.fxml "C:\Users\aposk\Desktop\Twitter_App_Win_Version\app\ressources\pip-0.0.1-SNAPSHOT.jar"

pause

我们正在研究 JDK 13,但也适用于 JDK --> 通过导入 java.net 产生 Http 请求的原因。

我使用的是 Win-64bits,并且使用 Maven 来处理 Eclipse。网络上的其他解决方案没有解决我的问题

最佳答案

带着解决方案回来!

如果您需要使用 JFX 比 JAVA 8 更新的版本运行 .jar,您需要使用 jdk 设置系统,而且还需要创建一个新的主类,而不扩展应用程序。在此类中,您将使用 public void 方法运行 mainApp,并且需要在 pom.xml (feg) 中添加一些参数

<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>2.4.1</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<shadedArtifactAttached>true</shadedArtifactAttached>
							<shadedClassifierName>project/classifier</shadedClassifierName>
							<outputFile>shade\${project.artifactId}.jar</outputFile>
							<transformers>
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>fr.tse.fise2.pip.graphic.Main</mainClass>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>

您还需要在 pom.xml 中为 java fx 配置一些模块

<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-base</artifactId>
			<version>13</version>
		</dependency>

		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-controls</artifactId>
			<version>13</version>
		</dependency>

		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-graphics </artifactId>
			<version>13</version>
			<classifier>mac</classifier>
		</dependency>

		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-graphics </artifactId>
			<version>13</version>
			<classifier>linux</classifier>
		</dependency>

		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-graphics </artifactId>
			<version>13</version>
			<classifier>win</classifier>
		</dependency>

		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-fxml</artifactId>
			<version>13</version>
		</dependency>

		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-web</artifactId>
			<version>13</version>
		</dependency>
    
    	<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-controls</artifactId>
			<version>13</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
		<dependency>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-fxml</artifactId>
			<version>13</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.jfoenix/jfoenix -->
		<dependency>

现在您可以在 jar 的正确位置使用 cmd java -jar filename.jar 运行 jar

我的项目适用于 JavaFx 和 JAVA 11

卡米尔的帮助

关于java.lang.IllegalArgumentException : plexus.container.default:无效的模块名称: 'default'不是Java标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59693916/

相关文章:

windows - 为什么 TVM_GETITEM 消息在 comctl32.ocx 或 mscomctl.ocx TreeView 上失败?

c++ - 使用C++学习Windows服务

java - 使用 spring "cvc-elt.1: Cannot find the declaration of element ' beans 获取错误消息。”

java - javaws 退出代码真的坏了吗?

Java JDBC 连接在方法之间共享/中继

java - 生成 json 时,我可以让 MOXy 将字符串转换为 boolean 值吗

c - 如何在 Windows 10 上安装用于 C/C++ 并行编程的英特尔 Cilk?

android - "App Engine Connected Android Project"不可用

java - cxf-xjc-plugin :3. 3.0 中的 Maven MojoExecutionException

java - 如何禁用 JSpinner 的键盘和鼠标输入?