简体   繁体   中英

Running a class that relies on Jar file in terminal

For my intro computer science class they recommend using eclipse as an IDE. I have used vim in the past and would prefer using it. There are two .jar files that the programs we create rely off of, because it is an intro class and we are not using java's main class functionality.

Right now we download the two .jar files and then use the Eclipse IDE build path function to link the .jar files with our code. Then when we run on Eclipse IDE it works perfectly fine.

How would I do this in ubuntu terminal? Thank you!

TLDR; Intro comp sci class wants us to use eclipse, I want to use vim. How do you build path for a jar file to work with my class code in the ubuntu terminal.

Looked at this link and did not work Java: how to import a jar file from command line

Update of image 在此处输入图片说明

You specify the jar files with a CLASSPATH, either using a CLASSPATH environment variable

export CLASSPATH="a.jar:b.jar"
java com.mypackage.MyClass

or on the command line with -cp like

java -cp a.jar:b.jar com.mypackage.MyClass

从命令行执行时包括jar依赖项。

java -cp tester.jar lab1

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM