[英]Java binary compatibility issue: sun.font.FontManager class became interface
I am using the Lobo - Java Web Browser library, and it gives me an exception which after some research I determined could be due to the library having been complied against an older version of Java. 我正在使用Lobo - Java Web浏览器库,它给了我一个例外,经过一些研究后我确定可能是因为该库已经与旧版本的Java进行了编译。
The code is as follows: 代码如下:
import java.io.IOException;
import org.lobobrowser.html.UserAgentContext;
import org.lobobrowser.html.parser.DocumentBuilderImpl;
import org.lobobrowser.html.parser.InputSourceImpl;
import org.lobobrowser.html.test.SimpleUserAgentContext;
import org.xml.sax.SAXException;
public class Cobratest
{
public static void main(String[] args) throws SAXException, IOException
{
UserAgentContext uAgent = new SimpleUserAgentContext();
DocumentBuilderImpl docBuild = new DocumentBuilderImpl(uAgent);
docBuild.parse(new InputSourceImpl("http://dic.amdz.com/"));
}
}
and the stack trace is: 并且堆栈跟踪是:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface sun.font.FontManager, but class was expected
at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:210)
at org.lobobrowser.util.gui.FontFactory.createFont_Impl(FontFactory.java:180)
at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:127)
at org.lobobrowser.util.gui.FontFactory.getFont(FontFactory.java:98)
at org.lobobrowser.html.style.StyleSheetRenderState.<clinit>(StyleSheetRenderState.java:43)
at org.lobobrowser.html.domimpl.NodeImpl.<clinit>(NodeImpl.java:39)
at org.lobobrowser.html.parser.DocumentBuilderImpl.createDocument(DocumentBuilderImpl.java:143)
at org.lobobrowser.html.parser.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:97)
when I examined org.lobobrowser.util.gui.FontFactory.createFont
I found out there is an interface called FontManager
which changed from the previous version of Java. 当我检查org.lobobrowser.util.gui.FontFactory.createFont
我发现有一个名为FontManager
的接口,它改变了以前的Java版本。 In this FontFactory
class, they used a class of this interface which is no longer available. 在这个FontFactory
类中,他们使用了一个不再可用的接口类。 How can I fix this problem? 我该如何解决这个问题?
the interface FontManager
: 接口FontManager
:
package sun.font;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.File;
public interface FontManager {
public static final int NO_FALLBACK = 0;
public static final int PHYSICAL_FALLBACK = 1;
public static final int LOGICAL_FALLBACK = 2;
public boolean registerFont(Font font);
public void deRegisterBadFont(Font2D font2d);
public Font2D findFont2D(String string, int i, int i1);
public Font2D createFont2D(File file, int i, boolean bln, CreatedFontTracker cft) throws FontFormatException;
public boolean usingPerAppContextComposites();
public Font2DHandle getNewComposite(String string, int i, Font2DHandle fdh);
public void preferLocaleFonts();
public void preferProportionalFonts();
}
and the class used in the library which is not available: 和库中使用的类不可用:
return FontManager.getCompositeFontUIResource(new Font(name, style, size));
我认为'sun.font.FontManager'是用Java7删除的,所以如果你必须使用它(我建议反对它并寻找另一个包)你可以尝试用java6运行它。
The lobobrowser project is dead, but some nice user comittet a patch to fix your problem: lobobrowser项目已经死了,但是一些不错的用户可以通过补丁修复你的问题:
http://sourceforge.net/tracker/?func=detail&aid=2991043&group_id=139023&atid=742262 http://sourceforge.net/tracker/?func=detail&aid=2991043&group_id=139023&atid=742262
Since a dead project doesn't release any patched jars, I did it ;-) Find a cobra-gp-0.98. 由于一个死的项目没有发布任何修补的罐子,我做了它;-)找到一个cobra-gp-0.98。 5 .jar with the above patch applied at : http://www.wikisquare.de/public/cobra-gp-0.98.5.jar 5 .jar上面的补丁适用于: http : //www.wikisquare.de/public/cobra-gp-0.98.5.jar
javax.swing.text.StyleContext.getDefaultStyleContext.getFont might work for you, across JDK releases. 在JDK版本中,javax.swing.text.StyleContext.getDefaultStyleContext.getFont可能适合您。
See further http://elliotth.blogspot.com.au/2007/04/far-east-asian-fonts-with-java-7-on.html 进一步了解http://elliotth.blogspot.com.au/2007/04/far-east-asian-fonts-with-java-7-on.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.