在eclipse中可以给jar包设置一个源码包,但是这个源码包的编码格式没有办法单独设置,管理源码包的类是org.eclipse.jdt.internal.core.SourceMapper,其中的构造函数是:
public SourceMapper(IPath sourcePath, String rootPath, Map options) {
this.areRootPathsComputed = false;
this.options = options;
try {
this.encoding = ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset();
} catch (CoreException e) {
// use no encoding
}
if (rootPath != null) {
this.rootPaths = new ArrayList();
this.rootPaths.add(rootPath);
}
this.sourcePath = sourcePath;
this.sourceRanges = new HashMap();
this.parameterNames = new HashMap();
this.importsTable = new HashMap();
this.importsCounterTable = new HashMap();
}
可以看到代码:ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset(),编码是workspace的defaultCharset,可以通过window -> Preferences -> General -> Workspace设置。
希望能在eclipse3.6以后的版本中解决这个问题