I'm working with JGraphT API and trying to compile and run this demo ( https://raw.githubusercontent.com/jgrapht/jgrapht/master/jgrapht-demo/src/main/java/org/jgrapht/demo/HelloJGraphT.java ).
My current directory contains the .java file and the directory called jgrapht-0.9.1. jgrapht-0.9.1 contains the folder lib where all the .jar files are.
I've successfully compiled the file using:
javac -cp ./jgrapht-0.9.1/lib/*: HelloJGraphT.java
But I'm having difficulty running the program. I have tried:
java -cp ./jgrapht-0.9.1/lib/*: HelloJGraphT
java -cp "./jgrapht-0.9.1/lib/*:" HelloJGraphT
java -cp "./jgrapht-0.9.1/lib/*:." HelloJGraphT
Yet none of them worked. I am really confused about the syntax of classpath, and really appreciate any help!
First, you must write the full name of the main class:
java -cp "jgrapht-0.9.1/lib/*:." org.jgrapht.demo.HelloJGraphT
Second, I am assuming that the compiled class is in directory structure in the current directory:
org/jgrapht/demo/HelloJGraphT.class
Third, you must use JDK6 or above in order to use wildcard in classpath.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.