我们有一个桌面应用程序,我们在其中打包应用程序 Jar 和 JRE,以避免客户机器中的 Java 依赖。
但问题是客户是否已经在机器中安装了 Java。由于某些类的 Java 版本依赖关系,我们面临没有类定义异常之类的问题。
现在我的问题是如何始终使用与应用程序一起打包的 JRE 启动应用程序,并确保它在安装后不使用系统 JRE。
C:\Users\User\Nokia\1830 PSS-APA>jre\bin\java -jar apat.jar
Exception in thread "ApaPowerControlChart" java.lang.NoClassDefFoundError: Could
not initialize class sun.font.SunFontManager
at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
at sun.swing.SwingUtilities2.getFontMetrics(Unknown Source)
at javax.swing.JComponent.getFontMetrics(Unknown Source)
at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.GridLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JRootPane$RootLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at java.awt.Window.pack(Unknown Source)
at com.nokia.APA.Chart.ApaPowerControlChart.display(Unknown Source)
at com.nokia.APA.Chart.ApaPowerControlChart$1.run(Unknown Source)
Exception in thread "ApaPowerControlChart" java.lang.NoClassDefFoundError: Could
not initialize class sun.font.SunFontManager
at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
at sun.swing.SwingUtilities2.getFontMetrics(Unknown Source)
at javax.swing.JComponent.getFontMetrics(Unknown Source)
at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.GridLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JRootPane$RootLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at java.awt.Window.pack(Unknown Source)
at com.nokia.APA.Chart.ApaPowerControlChart.display(Unknown Source)
at com.nokia.APA.Chart.ApaPowerControlChart$1.run(Unknown Source)
Exception in thread "ApaPerformanceChart" java.lang.NoClassDefFoundError: Could
not initialize class sun.font.SunFontManager
at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
at sun.swing.SwingUtilities2.getFontMetrics(Unknown Source)
at javax.swing.JComponent.getFontMetrics(Unknown Source)
at javax.swing.plaf.basic.BasicTabbedPaneUI.getFontMetrics(Unknown Sourc
e)
at javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabWidth(Unknown
Source)
at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout.calculateSi
ze(Unknown Source)
at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout.preferredLa
youtSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JRootPane$RootLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at java.awt.Window.pack(Unknown Source)
at com.nokia.APA.Chart.ApaPerformanceChart.display(Unknown Source)
at com.nokia.APA.Chart.ApaPerformanceChart$1.run(Unknown Source)
Exception in thread "ApaChannelTuningChart" java.lang.NoClassDefFoundError: Coul
d not initialize class sun.font.SunFontManager
at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
at sun.swing.SwingUtilities2.getFontMetrics(Unknown Source)
at javax.swing.JComponent.getFontMetrics(Unknown Source)
at javax.swing.plaf.basic.BasicTabbedPaneUI.getFontMetrics(Unknown Sourc
e)
at javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabWidth(Unknown
Source)
at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout.calculateSi
ze(Unknown Source)
at javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout.preferredLa
youtSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JRootPane$RootLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.BorderLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at java.awt.Window.pack(Unknown Source)
at com.nokia.APA.Chart.ApaChannelTuningChart.display(Unknown Source)