Recently with Neatbeans 6.9.1 do development, found in the Neatbeans environment run no problem, but in the command line can not run normally, Baidu a bit originally need to add classpath command, but found still can not run normally, finally after my many tests, Originally used Classpath to cover the original classpath, directly resulting in the original main class can not be found. /* This class is packaged into Javalibrary1.jar, and I use the jar file generated directly by NetBeans *//*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/package liguojun;/**
*
* @author Administrator
*/
public class Dragon {
int length=100;
int age = 100;
Public Dragon (int alength, int aage) {
length = Alength;
age = Aage;
}
public void Fly () {
System.out.println (this+ "flying");
}}/* The class uses the Dragon class in Javalibrary1.jar. *//*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/package javaapplication5;
Import liguojun.*;/**
*
* @author Administrator
*/
public class Main {/**
* @param args the command line arguments
*/
public static void Main (string[] args) {
TODO Code application logic here
Dragon dragon=new Dragon (100,20);
Dragon.fly ();
}
}
Here is the corresponding command line: Compile: Javac
-classpath D:\lgj\java\code\javaapplication5\JavaLibrary1.jarD:\lgj\java\code\javaapplication5\Main.java Run: Java-classpath D:\lgj\java\code\javaapplication5\JavaLibrary1.jar ;
D:\lgj\java\codeJavaapplication5. Main
The run-time D:\lgj\java\code is required, otherwise the JAVAAPPLICATION5 cannot be found. Main class
Use of command line Java-classpath