I am trying to write a program that prints out a statement through Linux. The catch is that most of the statement must come from a method from a jar file. Basically. my code looks like this
public class identification {
public static void main(String[] args){ // Main method with print statement
System.out.print("I am " + person());
}
}
The person() method comes from the jar file. It should give something like "I am bob on a computer," but I can't quite figure out how to set up the CLASSPATH environment variable in the .bash_profile so it reads the method from the jar file. Any ideas? I am sure this is a simple task.
Thank you for your time.
use cp
command to add a jar file
java -cp lib/myJar.jar myPackage.Program
also I believe you may need to import
class where method person
is in. I don't know how your hierarchy is so I can't help you with that.
您可以像这样在您的类路径中添加一个jar:
export CLASSPATH=$CLASSPATH:/path/to/your/myJar.jar
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.