matlab javaaddpath不再工作了(用jdk 1.7构建的jar) [英] matlab javaaddpath not working anymore (with jar built with jdk 1.7)
问题描述
我正在使用外部jar(由我开发)到我的matlab projet(由我开发)和javaaddpath命令。
I'm using an external jar (developped by me) into my matlab projet (developped by me) with javaaddpath command.
我已经更新了我的编程环境Matlab r2011a到r2012b,jdk从1.6.0_29到1.7.0_09,windows从XP到Seven。
I have updated my programming environnement from Matlab r2011a to r2012b, jdk from 1.6.0_29 to 1.7.0_09 and windows from XP to Seven.
首先我没有重新编译我的jar文件,我的整个项目是仍在工作(没有bug运行)。
Firstly I have not recompiled my jar file, and my whole project is still working (running without bug).
但是现在,我正在尝试重新编译我的jar文件。我遇到了一些问题,但它已经解决了(参见: javac @< opiton_file>和encoding )。但是现在我的jar工具被重建了,我无法将其用于matlab ... Matlab显示错误:
But now, I'm trying to recompile my jar file. I had some problem with that, but it solved (see: javac @<opiton_file> and encoding). But now that my jar tool is rebuilt, I can't use it into matlab... Matlab display the error:
Undefined variable "optimizer" or function "optimizer.Gui".
其中optimizer是一个包(即jar文件中的目录,包含Gui类的目录) 。
where optimizer is a package (ie a directory inside the jar file, directory which contain a Gui class).
总结一下,我正在使用代码(最后一行必须弹出一个JFrame):
To summarize, I'm using the code (the last line must popup a JFrame) :
javaaddpath('the full path of my jar file.jar');
optimizer.Gui;
在不更新jar文件的编译版本的情况下,它正在运行。使用新版本(相同的源代码),matlab输出错误。
Without updating the compiled version of the jar file, it's working. With the new version (same source code), matlab output the error.
我在jar文件的根目录下有一个Main类(包含一个main函数)和一个manitifest将此Main类指定为主类。这个Main类进行了一些测试,以确保jar文件中的所有功能都正常工作。所以我可以运行java -jar my_jar_file.jar并看到所有测试都正常(其中一个测试显示我的optimizer.Gui)。
I have a Main class (containing a main function) at the root of the jar file and a manitifest specifying this Main class as the main class. This Main class make some test, to ensure all the functionnalities into the jar file is working. So I can run java -jar my_jar_file.jar and see that all test are OK (one of the test displayed my optimizer.Gui).
是否存在不兼容性javac版和matlab?是因为我在文件编码方面遇到了一些麻烦?...
Is there an incompatibility of the javac version and matlab? Of is it because I had some trouble with file encoding?...
推荐答案
好的,我已经重新安装了JDK 1.6.0_37(最后一个可用的1.6版本)。
我使用了我的构建工具(create_jar.bat),只是强制通向这个旧的jdk。
它在Matlab r2012b下的工作就像魅力一样!
Ok, I've re-installed the JDK 1.6.0_37 (the last avaible 1.6 version). I've used my build tool (create_jar.bat), by just forcing the path to this old jdk. And it's working like a charm under Matlab r2012b!
- > Matlab r2012b与使用jdk 1.7构建的jar文件不兼容。
--> Matlab r2012b is not compatible with jar file built with the jdk 1.7.
(谢谢Matworks不要阻止此事。)
(Thank you Matworks to not prevent from this).
这篇关于matlab javaaddpath不再工作了(用jdk 1.7构建的jar)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!