我正在尝试使用 JNA,因为我想使用用 C++ 编写的 .dll,而其余代码是用 Java 编写的。但是,如果我尝试导入 JNA 类,Eclipse 会声明“com.sun.jna.Library 类型不可访问”。
我的 IDE 似乎发现 JNA 以某种方式存在于我的库中,因为当我输入“import com.sun.j”时,它会向我推荐 .jna 和 .jar 文件中的其他包。
我创建了一个单独的项目来看看它是否在那里工作,但它就是不起作用。
我已经从 jna Github( https://github.com/java-native-access/jna/blob/)下载了最新的 .jar(jna-5.8.0.jar 和 jna-platform-5.8.0.jar)文件master/README.md),我已通过项目 - >配置构建路径 - >添加外部JAR将它们添加到类路径中
我正在使用 Eclipse 和 javaSE-13。
package Testtest;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Run Code Online (Sandbox Code Playgroud)
封装结构:
Test
|-- src
| |-- TestTest
| | |-- Main.java
| |-- module-info.java
|-- …Run Code Online (Sandbox Code Playgroud) 我正在将旧版 Java 8 项目迁移到 Java 11。
该项目正在使用此类,javax.xml.rpc.Service
它是之前从库/jar 中获取的(我的意思是在 Java 8 中):jaxrpc.jar
但由于我要迁移到 Java 11,并且必须遵守“唯一可见性”的要求
(请参阅/sf/answers/3767726931/),
我必须删除包含此类的 JAR javax.xml.rpc.Service(jaxrpc.jar)来自我的项目...因为现在(在 Java 11 中,实际上是从 Java 9 开始)只有一个模块必须提供/公开javax.xml.rpcpackage。但我不认为这个Service类在JDK中。
那么我该如何解决这个问题呢?
我仍然需要javax.xml.rpc.Service,但我无法使用该类所在的罐子。我似乎被困在这里。
顺便说一句,我也有同样的问题javax.xml.rpc.ServiceException
解决此类问题的正确方法是什么?
我正在按照http://openjdk.java.net/projects/jigsaw/quick-start中的Java 9 Jigsaw早期访问版快速入门指南中的步骤进行操作
? tmp java --version
java 9-ea
Java(TM) SE Runtime Environment (build 9-ea+172)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+172, mixed mode)
Run Code Online (Sandbox Code Playgroud)
jar命令从正确的Java 9目录中获取.
? tmp which jar
/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/jar
Run Code Online (Sandbox Code Playgroud)
快速入门指南中的一个步骤说使用--print-module-descriptor选项运行jar命令但是当我尝试时,我收到下面的错误消息.
? tmp jar --print-module-descriptor --file=mlib/org.astro@1.0.jar
unrecognized option : --print-module-descriptor
Try `jar --help' for more information.
Run Code Online (Sandbox Code Playgroud)
看起来这个选项在最新的早期访问构建中不存在它是删除还是移动到其他地方?jar --help输出如下以供参考
? tmp jar --help
Usage: jar [OPTION...] [ [--release VERSION] [-C dir] files] ...
jar creates an archive for classes and resources, and can manipulate …Run Code Online (Sandbox Code Playgroud) 我们有一个不使用AWT / Swing / JavaFX的Java应用程序,并且可以与私有捆绑的JRE 8一起正常工作。JRE9远远大于JRE 8,但是我们想让用户使用JRE 9来尝试我们的应用程序。但仍想对我们的代码或jar进行模块化(以保持与Java 8的兼容性)。
如何创建可以与该Java应用程序捆绑在一起的“必需的”(精简到最少的必需部分)私有JRE 9?
在module-info.java我得到错误
包“ com.example”从“ javafx.base”和“ javafx.base”两者中读取包“ javafx.beans”。
迁移(从Java 8到Java 11)不仅使我感到沮丧,而且肯定会令我沮丧,这个错误对我没有任何意义。
我的依赖部分build.gradle:
def springFrameworkVersion = '5.1.2.RELEASE'
def hibernateVersion = '5.3.7.Final'
def junitJupiterVersion = '5.3.1'
dependencies {
compile 'org.transentials:cardhouse-commons:1.1.1'
compile 'ch.qos.logback:logback-classic:1.2.3'
compile "org.springframework:spring-context:$springFrameworkVersion"
compile "org.springframework:spring-jdbc:$springFrameworkVersion"
compile "org.springframework:spring-orm:$springFrameworkVersion"
compile "org.hibernate:hibernate-core:$hibernateVersion"
compile 'org.apache.commons:commons-dbcp2:2.5.0'
compile 'org.apache.commons:commons-lang3:3.8.1'
compile 'commons-io:commons-io:2.6'
compile 'com.h2database:h2:1.4.197'
compile 'javax.xml.bind:jaxb-api:2.3.1'
compile 'com.google.guava:guava:27.0-jre'
compile 'org.flywaydb:flyway-core:5.2.1'
compile 'javax.validation:validation-api:2.0.1.Final'
compile "org.openjfx:javafx-base:11:$platform"
compile "org.openjfx:javafx-graphics:11:$platform"
compile "org.openjfx:javafx-controls:11:$platform"
compile "org.openjfx:javafx-fxml:11:$platform"
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.+'
testCompile 'de.saxsys:jfx-testrunner:1.2'
testCompile 'org.apache.commons:commons-text:1.6'
testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testCompile "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
testCompile 'org.hamcrest:hamcrest-all:1.3'
}
Run Code Online (Sandbox Code Playgroud)
和 …
java java-platform-module-system java-module java-11 javafx-11
我有一个小项目,当我让它运行时确实会引发异常。
问题在这里(TestObject.java):
final JAXBContext jaxbContext = JAXBContext.newInstance(...);
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么会抛出异常。我还创建了一个像超级按钮一样工作的测试(TestTest.java)。请原谅我的名字,但这只是一个小的测试应用程序,它可以与Java 11一起使用。
我遵循以下步骤:javax.xml.bind.JAXBException在模块路径或类路径上未找到 并添加了JAXB-API的实现
compile('javax.xml.bind:jaxb-api:2.3.0')
compile('javax.activation:activation:1.1')
compile('org.glassfish.jaxb:jaxb-runtime:2.3.0')
Run Code Online (Sandbox Code Playgroud)
到我的build.gradle,但随后它抱怨
Error:java: module not found: java.activation
Run Code Online (Sandbox Code Playgroud)
不见了。由于这也从Java 11中删除,因此我添加了:
compile 'com.sun.activation:javax.activation:1.2.0'
Run Code Online (Sandbox Code Playgroud)
但随后引发了很多错误:
Error:java: the unnamed module reads package com.sun.xml.bind from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.util from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.marshaller from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.api from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads …Run Code Online (Sandbox Code Playgroud) 鉴于我的module-info.java:
module my_module {
requires lucene.analyzers.common;
requires lucene.core;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
模块“my_module”从“lucene.analyzers.common”和“lucene.core”中读取包“org.apache.lucene.analysis.standard”
在我的代码中,我使用以下导入:
// import from lucene.analyzers.common
import org.apache.lucene.analysis.util.TokenizerFactory;
// import from lucene.core
import org.apache.lucene.analysis.TokenStream;
Run Code Online (Sandbox Code Playgroud)
如何解决这个拆分包问题?
我正在用 maven 构建一个 java 项目。我想确定几件事:
我应该如何配置 maven-compiler-plugin?谢谢。
原始存储库位于https://github.com/cyanpotion/SDL_GameControllerDB_Util
现在我可以通过 2 和 3,但是输出 jar 似乎无法在 jre8 上运行。
我尝试运行一个使用 java 9 模块的非常简单的 gradle 项目,但收到以下错误。
/home/vadim/IdeaProjects/test_modules/src/main/java/module-info.java:2: error: module not found: HdrHistogram
requires HdrHistogram;
^
Run Code Online (Sandbox Code Playgroud)
这是https://github.com/vad0/test_modules。主类基本上什么都不做。
package app;
import org.HdrHistogram.Histogram;
public class RunHdr {
public static void main(String[] args) {
final Histogram histogram = new Histogram(5);
System.out.println(histogram);
}
}
Run Code Online (Sandbox Code Playgroud)
它只使用一个依赖项:HdrHistogram。我根据官方 gradle 教程https://docs.gradle.org/current/samples/sample_java_modules_multi_project.html在 build.gradle 中包含了这个魔术命令。
java {
modularity.inferModulePath = true
}
Run Code Online (Sandbox Code Playgroud)
整个 build.gradle 看起来像这样。
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
java {
modularity.inferModulePath = true
}
dependencies {
compile group: …Run Code Online (Sandbox Code Playgroud) java ×10
java-platform-module-system ×10
java-9 ×4
java-11 ×3
java-8 ×2
java-module ×2
gradle ×1
hdrhistogram ×1
jar ×1
javafx-11 ×1
jna ×1
lucene ×1
maven ×1