yin
yin

Reputation: 117

How to run Java program from any arbitrary directory inside Terminal

I saw some other similar posts, but they didn't seem to answer my question.

I have a package of java files, and the java functions inside one file call java functions from a different file. Right now I am limited to run my program from the parent directory of gitlet as shown in the screenshot. Is there a way to run my java program from any arbitrary directory?

P.S. I am hoping to get a solution that can be done just inside terminal.

screenshot of package

Upvotes: 2

Views: 53

Answers (2)

Antoniossss
Antoniossss

Reputation: 32517

From anywhere

java -cp path/to/my/compiled/classes/directory1 fully.qualified.name.of.BootstrapClass

Upvotes: 4

Code-Apprentice
Code-Apprentice

Reputation: 83527

Is there a way to run my java program from any arbitrary directory?

Yes, you can add the base directory that contains the compiled .class files to the CLASSPATH environment variable.

Upvotes: 2

Related Questions