用这个看看:jar -cvfm MyJar.jar manifest.mf *.class
java,什么时候才能到达境界呢?
好啊!多谢你了
import java.awt.Graphics;
import javax.swing.*;
public class Line extends JApplet
{
int x1,x2,y1,y2;
public void init()
{
String nStr1=JOptionPane.showInputDialog("请输入第一个点的横坐标x1:");
x1=Integer.parseInt(nStr1);
String nStr2=JOptionPane.showInputDialog("请输入第二个点的纵坐标y1:");
y1=Integer.parseInt(nStr2);
String nStr3=JOptionPane.showInputDialog("请输入第三个点的横坐标x2:");
x2=Integer.parseInt(nStr3);
String nStr4=JOptionPane.showInputDialog("请输入第四个点的纵坐标y2:");
y2=Integer.parseInt(nStr4);
}
public void paint(Graphics g)
{
g.drawLine(x1,y1,x2,y2);
}
}
我在运行AWT程序(里面有main()方法)出现如下异常:
java.lang.ClassCastException:Oval
at sun.applet.AppletPanel.createApplet(AppletPanel.java:721)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:650)
at sun.applet.AppletPanel.run(AppletPanel.java:324)
at java.lang.Thread.run(Thread.java:595)
源代码:
import java.awt.*;
public class MLine extends Frame
{
static MLine frm=new MLine();
public static void main(String args[])
{
frm.setTitle("Polygon");
frm.setSize(200,150);
frm.setVisible(true);
}
public void paint(Graphics g)
{
int x[]={44,65,97,139,58};
int y[]={34,55,40,109,127};
g.setColor(Color.pink);
g.fillPolygon(x,y,5);
g.setColor(Color.red);
g.drawPolygon(x,y,5);
}
}
我用javac Oval.java能正常编译,但是当我用appletviewer Oval.html运行时就出现异常。
我觉得是不是我的JDK有问题啊。