Use of command line Java-classpath

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.