本文介绍了Delphi 10.1 Berlin-Java2OP:预期的类或接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Delphi 10.1 Berlin.我想从Delphi调用Java代码.因此,我在Android Studio中创建了JAR文件(此链接对我有帮助).然后我从C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\converters\java2op目录打开Java2OP.exe.我将jar文件移动到此目录.然后,我在CMD中处理了以下命令:
SET PATH=%PATH%;"C:\Program Files\Java\jdk1.8.0_60\bin"
Java2OP.exe -jar ..\libmylib.jar -unit ..\Androidapi.JNI.MyLib
但是我得到这个错误:

I'm using Delphi 10.1 Berlin. I want to call Java codes from Delphi. So, I created JAR file in Android Studio (this link helped to me). Then I opened Java2OP.exe from C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\converters\java2op directory. I moved the jar file to this directory. Then I worked this commands in CMD:
SET PATH=%PATH%;"C:\Program Files\Java\jdk1.8.0_60\bin"
Java2OP.exe -jar ..\libmylib.jar -unit ..\Androidapi.JNI.MyLib
But I get this error:

Warning: error opening ReservedWordsOP.txt
Warning: error opening ReservedWordsC.txt
Parsing xml: C:\Program Files (x86)\Embarcadero\Studio\18.0\bin\converters\java2op\bootclasses.xml
Parsing jar: ..\libmylib.jar
class or Interface expected

这是我的JAR Java类:

This my Java class for JAR:

public class Test
{
  public String work()
  {
    return "Hello World!";
  }
}

我也尝试了不同的Java代码,但是结果是相同的.我该如何解决这个问题?

Also I tried different Java codes, but result is same. How can I solve this problem?

推荐答案

我遇到了同样的问题,并解决了从路径文件中删除空格的问题.可能Java2OP正在调用Java传递不带引号的路径.

I have the same problem, and solved it removing spaces from path files.Probably the Java2OP is calling the Java passing the path without quotes.

这篇关于Delphi 10.1 Berlin-Java2OP:预期的类或接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:58