关于程序运行的问题(入门级) 在dos下,该是javac Application1.java java Application1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jb的ide里指定的classpath和dos下的classpath可能不一样 执行javac Application1.java 时报错:javac Application1.javaE:\program\jb6\dzjstyle\dzj002\src\dzj002>javac application1.javaapplication1.java:20: 不能解析符号符号:类 Frame1位置:类 in dzj002.Application1 Frame1 frame = new Frame1(); ^application1.java:20: 不能解析符号符号:类 Frame1位置:类 in dzj002.Application1 Frame1 frame = new Frame1(); ^2 个错误 在dos下进入dzj001的上层目录。然后用java -cp . dzj001.Application1 在用javac时。你应该指定Frame1的类路径如:javac -classpath %classpath%;Frame1的类路径 application1.java 灰狼老师frame1与application1.java同在c:\dzj001 运行 java dzj001.Application1报错:Exception in thread "main" java.lang.NoClassDefFoundError: dzj001/Application1 程序源码如下:Application1.java-------------------------------------package dzj002;import javax.swing.UIManager;import java.awt.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Application1 { boolean packFrame = false; //Construct the application public Application1() { Frame1 frame = new Frame1(); //Validate frames that have preset sizes //Pack frames that have useful preferred size info, e.g. from their layout if (packFrame) { frame.pack(); } else { frame.validate(); } //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); } //Main method public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { e.printStackTrace(); } new Application1(); }}----------------------------------------------------------------Frame1.java-----------------------------------------------------------------package dzj002;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import javax.swing.border.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Frame1 extends JFrame { JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); JPanel jPanel1 = new JPanel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); BoxLayout2 boxLayout21 = new BoxLayout2(); JButton jButton3 = new JButton(); JButton jButton4 = new JButton(); JButton jButton5 = new JButton(); Border border1; JPanel jPanel2 = new JPanel(); JTabbedPane jTabbedPane1 = new JTabbedPane(); JPanel jPanel3 = new JPanel(); JPanel jPanel4 = new JPanel(); JPanel jPanel5 = new JPanel(); JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JTextPane jTextPane1 = new JTextPane(); PaneLayout paneLayout1 = new PaneLayout(); //Construct the frame public Frame1() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); border1 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98)); contentPane.setLayout(borderLayout1); this.setDefaultCloseOperation(3); this.setSize(new Dimension(640, 480)); this.setTitle("工程在家预算"); jPanel1.setLayout(boxLayout21); jButton1.setMaximumSize(new Dimension(79, 29)); jButton1.setMinimumSize(new Dimension(79, 29)); jButton1.setPreferredSize(new Dimension(79, 29)); jButton1.setToolTipText("sssssssss"); jButton1.setText("公车"); jButton2.setText("jButton2"); jButton3.setText("jButton3"); jButton4.setText("jButton4"); jButton5.setText("jButton5"); jPanel1.setBorder(BorderFactory.createEtchedBorder()); jPanel2.setLayout(paneLayout1); jTabbedPane1.setBackground(SystemColor.activeCaptionBorder); jTabbedPane1.setForeground(Color.blue); jTabbedPane1.setMinimumSize(new Dimension(40, 40)); jTabbedPane1.setPreferredSize(new Dimension(400, 250)); jLabel1.setBackground(SystemColor.activeCaptionText); jLabel1.setText("jLabel1"); jLabel2.setText("jLabel2"); jPanel3.setBackground(SystemColor.activeCaptionBorder); jPanel3.setToolTipText("我这么多年票友我跟你唱"); jTextPane1.setBackground(SystemColor.activeCaptionBorder); jTextPane1.setForeground(Color.blue); jTextPane1.setCaretColor(Color.white); jTextPane1.setEditable(false); jTextPane1.setText("俄啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊\n啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊/" + "n啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊"); contentPane.setMinimumSize(new Dimension(600, 480)); contentPane.setPreferredSize(new Dimension(600, 480)); contentPane.add(jPanel1, BorderLayout.NORTH); jPanel1.add(jButton1, null); jPanel1.add(jButton2, null); jPanel1.add(jButton3, null); jPanel1.add(jButton4, null); jPanel1.add(jButton5, null); contentPane.add(jPanel2, BorderLayout.CENTER); jPanel2.add(jTabbedPane1, new PaneConstraints("jTabbedPane1", "jTabbedPane1", PaneConstraints.ROOT, 1.0f)); jTabbedPane1.add(jPanel3, "第一段"); jPanel3.add(jLabel1, null); jTabbedPane1.add(jPanel4, "大家伙"); jPanel4.add(jLabel2, null); jTabbedPane1.add(jPanel5, "刘备上"); jPanel5.add(jTextPane1, null); jTabbedPane1.setSelectedComponent(jPanel4); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } }}----------------------------------------------------------------- 望大家帮忙式一下我用jb6 run一切正常从dos 运行死活不行 是这个包么?import com.borland.jbcl.layout.*;如何加载阿!英雄! xujian_xj(大灰狼)说的是对的,在dos下进入dzj001的上层目录,然后用java -cp . dzj001.Application1因为application1.java用到了frame1.java,可他不用import frame1.java这种形式,而是直接在application1.java中使用frame1 类。因为这两个文件同属一个package dzj001. java编译器可以认得。但必须从package这一级目录进行javac..>javac dzj001.frame1.java..>javac dzj001.application1.java..>java -cp . dzj001.application1 今天又抓狂了一天,问题依然没解决javac dzj001.frame1.java 报错:com.borland.jbcl.layout.云云但为什么在jb6中运行正常?(我装了两个jdk,和这个有关么?) 哪位可以提供线程死锁以及防止死锁的示例代码吗?谢谢! JTextPane能把某字符串替换为图片吗? Arraylist用法 Java正则中一串数字中后5位要匹配ABCDE这类,即ABCDE各代表不同的数字要怎么写?谢谢 怎么设置文本域不能修改? java 中有没有钩子呀 Java中怎样访问Sql Server中的BigInt型数据 java中有没有什么方法可以求出数据库表中的字段名?赋到一个String的数组中? 怎么用不了? 大家觉得哪一种开发工具更好用呢? scjp题又一问题 我是初学者,有两个问题请各位帮忙。。。
application1.java:20: 不能解析符号
符号:类 Frame1
位置:类 in dzj002.Application1
Frame1 frame = new Frame1();
^
application1.java:20: 不能解析符号
符号:类 Frame1
位置:类 in dzj002.Application1
Frame1 frame = new Frame1();
^
2 个错误
然后用java -cp . dzj001.Application1
如:javac -classpath %classpath%;Frame1的类路径 application1.java
frame1与application1.java同在c:\dzj001
Exception in thread "main" java.lang.NoClassDefFoundError: dzj001/Application1
Application1.java
-------------------------------------package dzj002;import javax.swing.UIManager;
import java.awt.*;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/public class Application1 {
boolean packFrame = false; //Construct the application
public Application1() {
Frame1 frame = new Frame1();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new Application1();
}
}----------------------------------------------------------------
Frame1.java
-----------------------------------------------------------------
package dzj002;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/public class Frame1 extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
BoxLayout2 boxLayout21 = new BoxLayout2();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
Border border1;
JPanel jPanel2 = new JPanel();
JTabbedPane jTabbedPane1 = new JTabbedPane();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextPane jTextPane1 = new JTextPane();
PaneLayout paneLayout1 = new PaneLayout(); //Construct the frame
public Frame1() { try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
border1 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98));
contentPane.setLayout(borderLayout1);
this.setDefaultCloseOperation(3);
this.setSize(new Dimension(640, 480));
this.setTitle("工程在家预算");
jPanel1.setLayout(boxLayout21);
jButton1.setMaximumSize(new Dimension(79, 29));
jButton1.setMinimumSize(new Dimension(79, 29));
jButton1.setPreferredSize(new Dimension(79, 29));
jButton1.setToolTipText("sssssssss");
jButton1.setText("公车");
jButton2.setText("jButton2");
jButton3.setText("jButton3");
jButton4.setText("jButton4");
jButton5.setText("jButton5");
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel2.setLayout(paneLayout1);
jTabbedPane1.setBackground(SystemColor.activeCaptionBorder);
jTabbedPane1.setForeground(Color.blue);
jTabbedPane1.setMinimumSize(new Dimension(40, 40));
jTabbedPane1.setPreferredSize(new Dimension(400, 250));
jLabel1.setBackground(SystemColor.activeCaptionText);
jLabel1.setText("jLabel1");
jLabel2.setText("jLabel2");
jPanel3.setBackground(SystemColor.activeCaptionBorder);
jPanel3.setToolTipText("我这么多年票友我跟你唱");
jTextPane1.setBackground(SystemColor.activeCaptionBorder);
jTextPane1.setForeground(Color.blue);
jTextPane1.setCaretColor(Color.white);
jTextPane1.setEditable(false);
jTextPane1.setText("俄啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊\n啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊/" +
"n啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊\n啊啊啊啊啊啊啊啊啊啊啊啊啊");
contentPane.setMinimumSize(new Dimension(600, 480));
contentPane.setPreferredSize(new Dimension(600, 480));
contentPane.add(jPanel1, BorderLayout.NORTH);
jPanel1.add(jButton1, null);
jPanel1.add(jButton2, null);
jPanel1.add(jButton3, null);
jPanel1.add(jButton4, null);
jPanel1.add(jButton5, null);
contentPane.add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jTabbedPane1, new PaneConstraints("jTabbedPane1", "jTabbedPane1", PaneConstraints.ROOT, 1.0f));
jTabbedPane1.add(jPanel3, "第一段");
jPanel3.add(jLabel1, null);
jTabbedPane1.add(jPanel4, "大家伙");
jPanel4.add(jLabel2, null);
jTabbedPane1.add(jPanel5, "刘备上");
jPanel5.add(jTextPane1, null);
jTabbedPane1.setSelectedComponent(jPanel4); }
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
-----------------------------------------------------------------
我用jb6 run一切正常
从dos 运行死活不行
如何加载阿!英雄!
在dos下进入dzj001的上层目录,然后用java -cp . dzj001.Application1因为application1.java用到了frame1.java,可他不用import frame1.java这种形式,而是直接在application1.java中使用frame1 类。
因为这两个文件同属一个package dzj001. java编译器可以认得。但必须从package这一级目录进行javac
..>javac dzj001.frame1.java
..>javac dzj001.application1.java..>java -cp . dzj001.application1
javac dzj001.frame1.java 报错:
com.borland.jbcl.layout.云云
但为什么在jb6中运行正常?
(我装了两个jdk,和这个有关么?)