JAVAEclipse:could not find the main class,program will exit!
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/10/01 02:25:57
JAVAEclipse:could not find the main class,program will exit!
我在Eclipse中写了以下一个程序:
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
//森林状的关系图
public class JTreeDemo
extends JFrame{
JTextField jtfInfo; //文本域,用于显示点击的节点名称
public JTreeDemo(){
super("森林状的关系图"); //调用父类构造函数
DefaultMutableTreeNode root = new DefaultMutableTreeNode("设置"); //生成根节点
DefaultMutableTreeNode node1=new DefaultMutableTreeNode("常规"); //生成节点一
node1.add(new DefaultMutableTreeNode("默认路径")); //增加新节点到节点一上
node1.add(new DefaultMutableTreeNode("保存选项"));
root.add(node1); //增加节点一到根节点上
root.add(new DefaultMutableTreeNode("界面"));
root.add(new DefaultMutableTreeNode("提示声音"));
root.add(new DefaultMutableTreeNode("打印"));
JTree tree = new JTree(root); //得到JTree的实例
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)tree.getCellRenderer(); //得到JTree的Renderer
renderer.setLeafIcon(null); //设置叶子节点图标为空
renderer.setClosedIcon(null); //设置关闭节点的图标为空
renderer.setOpenIcon(null); //设置打开节点的图标为空
tree.addTreeSelectionListener(new TreeSelectionListener() { //选择节点的事件处理
public void valueChanged(TreeSelectionEvent evt) {
TreePath path = evt.getPath(); //得到选择路径
String info=path.getLastPathComponent().toString(); //得到选择的节点名称
jtfInfo.setText(info); //在文本域中显示名称
}
});
JScrollPane jsp=new JScrollPane(tree); //增加JTree到滚动窗格
jtfInfo=new JTextField(); //实例化文本域
jtfInfo.setEditable(false); //文本域不可编辑
getContentPane().add(jsp,BorderLayout.CENTER); //增加组件到容器上
getContentPane().add(jtfInfo,BorderLayout.SOUTH);
setSize(250,200); //设置窗口尺寸
setVisible(true); //设置窗口可视
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗口时退出程序
}
public static void main(String[] args){
new JTreeDemo();
}
}
运行时跳出could not find the main class,program will exit!
谁帮我解决一下!谢谢
我用的是JDK1.4.2,Eclipse3.2
运行之后跳出这么一大段:
java.lang.UnsupportedClassVersionError: JTreeDemo (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Exception in thread "main"
我在Eclipse中写了以下一个程序:
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
//森林状的关系图
public class JTreeDemo
extends JFrame{
JTextField jtfInfo; //文本域,用于显示点击的节点名称
public JTreeDemo(){
super("森林状的关系图"); //调用父类构造函数
DefaultMutableTreeNode root = new DefaultMutableTreeNode("设置"); //生成根节点
DefaultMutableTreeNode node1=new DefaultMutableTreeNode("常规"); //生成节点一
node1.add(new DefaultMutableTreeNode("默认路径")); //增加新节点到节点一上
node1.add(new DefaultMutableTreeNode("保存选项"));
root.add(node1); //增加节点一到根节点上
root.add(new DefaultMutableTreeNode("界面"));
root.add(new DefaultMutableTreeNode("提示声音"));
root.add(new DefaultMutableTreeNode("打印"));
JTree tree = new JTree(root); //得到JTree的实例
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)tree.getCellRenderer(); //得到JTree的Renderer
renderer.setLeafIcon(null); //设置叶子节点图标为空
renderer.setClosedIcon(null); //设置关闭节点的图标为空
renderer.setOpenIcon(null); //设置打开节点的图标为空
tree.addTreeSelectionListener(new TreeSelectionListener() { //选择节点的事件处理
public void valueChanged(TreeSelectionEvent evt) {
TreePath path = evt.getPath(); //得到选择路径
String info=path.getLastPathComponent().toString(); //得到选择的节点名称
jtfInfo.setText(info); //在文本域中显示名称
}
});
JScrollPane jsp=new JScrollPane(tree); //增加JTree到滚动窗格
jtfInfo=new JTextField(); //实例化文本域
jtfInfo.setEditable(false); //文本域不可编辑
getContentPane().add(jsp,BorderLayout.CENTER); //增加组件到容器上
getContentPane().add(jtfInfo,BorderLayout.SOUTH);
setSize(250,200); //设置窗口尺寸
setVisible(true); //设置窗口可视
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗口时退出程序
}
public static void main(String[] args){
new JTreeDemo();
}
}
运行时跳出could not find the main class,program will exit!
谁帮我解决一下!谢谢
我用的是JDK1.4.2,Eclipse3.2
运行之后跳出这么一大段:
java.lang.UnsupportedClassVersionError: JTreeDemo (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Exception in thread "main"
我试过了,你的程序没有任何问题,你运行的方式可能不正确.
你在eclipse中用右键点击JTreeDemo.java文件“选择运行”->"java 应用程序"的方式运行试试,没问题的
————————————————————————
出现这个错误是由于你的jdk版本与eclipse高版本配置造成的,解决如下:
点击 窗口->首选项
点击编译器,把“编译器一致性级别”从5.0改成1.4试试吧
你在eclipse中用右键点击JTreeDemo.java文件“选择运行”->"java 应用程序"的方式运行试试,没问题的
————————————————————————
出现这个错误是由于你的jdk版本与eclipse高版本配置造成的,解决如下:
点击 窗口->首选项
点击编译器,把“编译器一致性级别”从5.0改成1.4试试吧
JAVAEclipse:could not find the main class,program will exit!
could not find the main class.profram will exit 异常
hiisi1.6.3为什么出现could not find the main class.program will ex
java初学者:Could not find the main class?
could find the main class:cz.vity.freerapid.core.MainApp.Pro
请问"can not find proper NIC,click OK to exit program"是什么意思?
install the driver fail!the program will exit这个是什么意思 我是升级台电C
Program exit
exit the unnecessatry program什么意思
the main difference is that to exit via an ipo will take lon
could not find the hardware这是什么意思
Error while read Texture "pic\note.peg"Program will exit.