user6535476
user6535476

Reputation:

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 imageenter image description here

Upvotes: 0

Views: 100

Answers (2)

suvartheec
suvartheec

Reputation: 3784

Include your jar dependencies while executing from command line.

java -cp tester.jar lab1

Upvotes: 0

Elliott Frisch
Elliott Frisch

Reputation: 201537

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

Upvotes: 2

Related Questions