java打包生成可执行文件 我用eclipse中export把一个工程文件打了包,里面有很多类和两幅图片,生成了一个.jar文件,用war打开有一个META-INF,之下的MANIFEST.MF打开是Manifest-Version: 1.0没有Created-By: 1.4.2 (Sun Microsystems Inc.)等等,之后再用exe4j生成可执行文件,可惜界面中不能显示图片,不知why? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好像应该是用getClass().getResource("RelativeImagePath")方法,如仍有问题,用JBuilder拖拽GUI出来,参照其自动生成的代码。 在安装过jsdk的机器上双击这个jar文件是否可以正常运行并显示图片,如果可以,则经过exe4j处理的exe文件应该没有问题,我曾经做过。否则你就要检查路径问题 图片的名字是英文的,jar文件双击有问题,import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MainFrame extends JFrame{ JButton btn1 =new JButton("函数说明"); JButton btn2 =new JButton("等距插值计算"); JButton btn3 =new JButton("不等距插值计算"); JButton btn4 =new JButton("误差分析"); JButton btn5 =new JButton("插值型求积"); JButton btn6 =new JButton("退出"); BorderLayout br =new BorderLayout(); JLabel jlab =new JLabel(); ImageIcon image =new ImageIcon("MainFrameShow.gif");//**** public MainFrame(){ super("数值计算中龙格现象模拟实现与分析"); btn1.addActionListener(new btn1ActionListener()); btn2.addActionListener(new btn2ActionListener()); btn3.addActionListener(new btn3ActionListener()); btn4.addActionListener(new btn4ActionListener()); btn5.addActionListener(new btn5ActionListener()); btn6.addActionListener(new btn6ActionListener()); jlab.setIcon(image); //******* Container cont =getContentPane(); cont.setLayout(new FlowLayout()); cont.add(btn1); cont.add(btn2); cont.add(btn3); cont.add(btn4); cont.add(btn5); cont.add(btn6); cont.add(jlab); getContentPane().setBackground(Color.BLUE); setVisible(true); validate(); } public static void main(String[] args) { MainFrame frame =new MainFrame(); frame.setLocation(221,180); frame.setSize(600,464); frame.show(); } class btn1ActionListener implements ActionListener{ public void actionPerformed(ActionEvent event){ AboutFrame aboutfrm =new AboutFrame(); aboutfrm.show(); } } class btn2ActionListener implements ActionListener{ public void actionPerformed(ActionEvent event){ Compute1Frame compute1frm =new Compute1Frame(); compute1frm.show(); } } class btn3ActionListener implements ActionListener{ public void actionPerformed(ActionEvent event){ Compute2Frame compute2frm =new Compute2Frame(); compute2frm.show(); } } class btn4ActionListener implements ActionListener{ public void actionPerformed(ActionEvent event){ AnalysisFrame analysisfrm =new AnalysisFrame(); analysisfrm.show(); } } class btn5ActionListener implements ActionListener{ public void actionPerformed(ActionEvent event){ CalculusFrame calculusfrm =new CalculusFrame(); calculusfrm.show(); } } class btn6ActionListener implements ActionListener{ public void actionPerformed(ActionEvent event){ System.exit(0); } }} 关于Thinking in java,有个问题问大家! 急!!!在eclipse中,如何对某个html不做验证? 一个超连接问题,请大家帮忙!先谢谢了! 在线等,#####一个简单的问题 请教IntelliJ IDEA 的问题 ? 一个关于JDBC的问题 要用OpenFileDialog控件的什么方法才能得到它返回的文件名? 第二次问同样的问题,难道真没有人知道答案吗? HTTP Status 404 - /Test/userLogin.action 新手问题!关于swing.Timer! 关于多线程控制 关于JTree的问题
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class MainFrame extends JFrame{
JButton btn1 =new JButton("函数说明");
JButton btn2 =new JButton("等距插值计算");
JButton btn3 =new JButton("不等距插值计算");
JButton btn4 =new JButton("误差分析");
JButton btn5 =new JButton("插值型求积");
JButton btn6 =new JButton("退出");
BorderLayout br =new BorderLayout();
JLabel jlab =new JLabel();
ImageIcon image =new ImageIcon("MainFrameShow.gif");//****
public MainFrame(){
super("数值计算中龙格现象模拟实现与分析");
btn1.addActionListener(new btn1ActionListener());
btn2.addActionListener(new btn2ActionListener());
btn3.addActionListener(new btn3ActionListener());
btn4.addActionListener(new btn4ActionListener());
btn5.addActionListener(new btn5ActionListener());
btn6.addActionListener(new btn6ActionListener());
jlab.setIcon(image); //*******
Container cont =getContentPane();
cont.setLayout(new FlowLayout());
cont.add(btn1);
cont.add(btn2);
cont.add(btn3);
cont.add(btn4);
cont.add(btn5);
cont.add(btn6);
cont.add(jlab);
getContentPane().setBackground(Color.BLUE);
setVisible(true);
validate();
}
public static void main(String[] args) {
MainFrame frame =new MainFrame();
frame.setLocation(221,180);
frame.setSize(600,464);
frame.show();
}
class btn1ActionListener implements ActionListener{
public void actionPerformed(ActionEvent event){
AboutFrame aboutfrm =new AboutFrame();
aboutfrm.show();
}
}
class btn2ActionListener implements ActionListener{
public void actionPerformed(ActionEvent event){
Compute1Frame compute1frm =new Compute1Frame();
compute1frm.show();
}
}
class btn3ActionListener implements ActionListener{
public void actionPerformed(ActionEvent event){
Compute2Frame compute2frm =new Compute2Frame();
compute2frm.show();
}
}
class btn4ActionListener implements ActionListener{
public void actionPerformed(ActionEvent event){
AnalysisFrame analysisfrm =new AnalysisFrame();
analysisfrm.show();
}
}
class btn5ActionListener implements ActionListener{
public void actionPerformed(ActionEvent event){
CalculusFrame calculusfrm =new CalculusFrame();
calculusfrm.show();
}
}
class btn6ActionListener implements ActionListener{
public void actionPerformed(ActionEvent event){
System.exit(0);
}
}
}