我很难在 .dll 中转换我的 .jar 库,并使其在IKVM框架下运行。 我编写了一个工作正常的Java库,因为它在几个java项目中已成功测试,但我强烈需要.dll for .NET。
当我启动命令时:
ikvm -jar mylib.jar
一切正常(我也尝试使用Main文件来确定:它有效)。
但是,当我输入:
ikvmc -target:library mylib.jar
我收到了很多警告,但仍然会创建.dll文件。重要的是要说所有警告都与我在项目中不使用的库有关,但我很确定我在Maven中导入的包对我来说是必不可少的。 我不知道真正的问题是否在这一步,因为我在线阅读忽略这些警告,但是为了确保我发布了一点输出:
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "javax.servlet.http.HttpServlet" not found
warning IKVMC0100: Class "javax.servlet.ServletOutputStream" not found
warning IKVMC0100: Class "org.junit.Assert" not found
warning IKVMC0100: Class "junit.framework.TestSuite" not found
warning IKVMC0100: Class "org.apache.tools.ant.taskdefs.MatchingTask" not found
让我们假设这一步没问题,现在我必须在我的C#app的 References 中导入IKVM库和mylib.dll文件。我做了,结果很奇怪:自动完成环境建议我只使用4个Java类,忽略99%的其他类。我认为出了问题,但我很难理解在哪里以及如何解决它。
更有用的信息:我正在使用Maven,Java8(sdk 1.8)和IKVM 8。 我也尝试过使用IKVM 7,但仍然遇到了同样的错误。 最后,这是我的pom.xml:
<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>org.fra.mylibrary</groupId>
<artifactId>MyLibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MYLIBRARY</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-distribution -->
<dependencies>
<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-distribution -->
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>4.1.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.antlr/antlr4-runtime -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.5.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/jfact -->
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>jfact</artifactId>
<version>4.0.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- ANTLR4 -->
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.5.3</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
<configuration>
</configuration>
</plugin>
<!-- Maven Assembly Plugin to create Jar -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:0)
只需删除与最新版本的方法和类相关的所有代码,并将其更改为java库的较低版本,可能有效,因为我有同样的错误