这么两个java文件
DemoMain.java:package demo;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;import javax.swing.JButton;
import javax.swing.JFrame;
import demo.DemoFrame;/*
 * Created on 2005-8-14
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 *//**
 * @author Tracy McGrady
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class DemoMain extends JFrame
{
private JButton frameBtn;

public DemoMain() 
{
setSize(300,200);
    setTitle("Demo Test");
    
    frameBtn = new JButton("New");
    frameBtn.addActionListener(new ActionListener()
{    
public void actionPerformed(ActionEvent e) 
{
DemoFrame newFrame = new DemoFrame();
newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
newFrame.show();
}
    });
    
    getContentPane().add(frameBtn,BorderLayout.CENTER);
}

public static void main(String[] args) throws SQLException, InstantiationException, IllegalAccessException
{  
DemoMain frame = new DemoMain();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.show();
}
}DemoFrame.javapackage demo;
import java.awt.BorderLayout;import javax.swing.JFrame;
import javax.swing.JLabel;/*
 * Created on 2005-8-14
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 *//**
 * @author Tracy McGrady
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class DemoFrame extends JFrame
{
private JLabel tmacLab;

public DemoFrame() 
{
setSize(300,200);
    setTitle("Demo Frame");
    
    tmacLab = new JLabel("Tracy McGrady!");
    getContentPane().add(tmacLab,BorderLayout.CENTER);
}
}把这两个java文件放在d:\demo下然后javac -d . d:\demo\*.java
这样编译所得在d:\demo\demo下放有class文件
在d:\demo下运行java demo.DemoMain可以运行
但是这时如果用jar打包就不成了!怎么弄都弄不出可以运行得jar文件!!!请问该怎么写jar命令可以在这里用啊????????????????

解决方案 »

  1.   

    用压缩软件打开JAR文件,里面有个META-INF,修改里面的文件,MAIN-CLASS: (你的主CLASS)
      

  2.   

    例如
    Manifest-Version: 1.0
    Main-Class: demo.DemoMain
    就可了,结帖吧
      

  3.   

    重写你的META-INF楼上的正解, 不过要注意最后要有个回车!
      

  4.   

    manifest.mf文件应该放在哪里?
      

  5.   

    是要问cmd的命令吗?
    d:\demo下敲
    jar -cvf demo.jar demodemo.jar 为你要打包为的jar文件名
    demo是你要打包的包名(也就是你类放的目录名)
      

  6.   

    答对问题不给分,严重 WangTracy8489(Tracy McGrady)