如何在Visual 2017解决方案中包含proxygen的"target"文件夹?



我已经成功地从Java生成了代理。NETusing jni4net proxygen.我现在正在尝试在Visual Studio 2017中创建.NET解决方案,并在.NET控制台程序中使用Java代理。我已经从代理生成导入了.dlls,它似乎可以工作,因为Visual Studio正在自动填充我的Java类(TempClientMain(,并且没有显示任何错误。

namespace ConsoleApp1
class Program 
{
     static void Main() 
     {
         var setup = new BridgeSetup(string[] args);
         setup.Verbose = true;
         setup.AddAllJarsClassPath("./");
         Bridge.CreateJVM(setup);
         Bridge.RegisterAssembly(typeof(TempClientMain).Assembly);
         TempClientMain test = new TempClientMain();
         test.run();
     }
}

但是,当我构建并运行它时,我得到以下cmd输出:

loading core from C:/Users/Ruben/source/repos/ConsoleApp1/ConsoleApp1/bin/x64/Debug/jni4net.n-0.8.8.0.DLL
loading jni4net.n-0.8.8.0, Version=0.8.8.0, Culture=neutral, PublicKeyToken=134a23405600bab4 from C:UsersRubensourcereposConsoleApp1ConsoleApp1binx64Debugjni4net.n-0.8.8.0.dll
loaded jni4net.n-0.8.8.0, Version=0.8.8.0, Culture=neutral, PublicKeyToken=134a23405600bab4 from C:UsersRubensourcereposConsoleApp1ConsoleApp1binx64Debugjni4net.n-0.8.8.0.dll
Initialized jni4net core
core loaded from C:/Users/Ruben/source/repos/ConsoleApp1/ConsoleApp1/bin/x64/Debug/jni4net.n-0.8.8.0.DLL
clr.version         :v4.0.30319
clr.arch            :64bit
java.home           :C:Program FilesJavajdk1.8.0_161
java.version        :1.8.0_161
sun.arch.data.model :64
loading mediasense.j4n, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null from C:UsersRubensourcereposConsoleApp1ConsoleApp1binx64Debugmediasense.j4n.dll
Unhandled Exception: net.sf.jni4net.jni.JNIException: Can't load java class for *MY TARGET PACKAGE PATH* from classLoader sun.misc.Launcher$AppClassLoader@c387f44 ---> java.lang.ClassNotFoundException: *MY TARGET PACKAGE PATH*
   at net.sf.jni4net.jni.JNIEnv.ExceptionTest()
   at net.sf.jni4net.jni.JNIEnv.CallObjectMethodPtr(IJvmProxy obj, MethodId methodIdNative, Value[] args)
   at java.lang.ClassLoader.loadClass(String par0)
   at net.sf.jni4net.utils.Registry.LoadClass(String name, ClassLoader classLoader, JNIEnv env)
   --- End of inner exception stack trace ---
   at net.sf.jni4net.utils.Registry.LoadClass(String name, ClassLoader classLoader, JNIEnv env)
   at net.sf.jni4net.utils.Registry.RegisterClass(RegistryRecord record, ClassLoader classLoader, JNIEnv env)
   at net.sf.jni4net.utils.Registry.BindJvm(RegistryRecord record, ClassLoader classLoader, JNIEnv env)
   at net.sf.jni4net.utils.Registry.BindJvm(RegistryRecord record, JNIEnv env)
   at net.sf.jni4net.utils.Registry.RegisterType(Type type, Boolean bindJVM, JNIEnv env)
   at net.sf.jni4net.utils.Registry.RegisterAssembly(Assembly assembly, Boolean bindJVM)
   at net.sf.jni4net.Bridge.RegisterAssembly(Assembly assembly)
   at ConsoleApp1.Program.Main(String[] args) in C:UsersRubensourcereposConsoleApp1ConsoleApp1Program.cs:line 21
Press any key to continue . . .

它加载正常,但似乎找不到目标文件夹。在我写我的目标包路径的地方,显示了与proxygens目标文件夹相同的包路径(没有大写字母(。我应该把它放在哪里,以便 .NET 程序可以找到它?我尝试将该文件夹粘贴到项目根目录和完成的构建文件夹中。当根本不包含它时,我也会收到错误。我对Visual Studio不是很熟悉,所以除了粘贴它以包含它之外,还有没有其他方法?

我只是在构建输出文件夹中缺少 Java 项目中的 jar 文件。这很令人困惑,因为包路径根本没有引用该 jar 文件,但它可以添加它。

相关内容

最新更新