Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 49538  / 3 Years ago, fri, october 22, 2021, 2:06:46

I've done java development before but generally on windows (but I'm by no means an expert).



I just want to set my CLASSPATH. When I run:



echo $CLASSPATH



(Is that right)? I get a empty line. So, it appears to me that my computer does not have a "Classpath" setup. What is the best practice to setup the classpath in Ubuntu (and linux in general)?



I'm using the default java for Ubuntu which should be OpenJDK. Not sure it's important, but I want to use Rhino (http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine)) Note: I've been able to install Rhino via the package manager. There is both documentation and rhnio packages. Then, the commands are js and rhino-debugger


More From » java

 Answers
4

I'm not a Java programmer, so I don't know the correct value for CLASSPATH. But, you seem to. You can add it to ~/.bashrc like so:



CLASSPATH=/path/to/1:/path/to/2:/etc


The change will take effect globally the next time you log in. However, it will take effect immediately in new shells.



Additionally, if you want to set it for just one particular command, do this:



CLASSPATH=/something command-here arg1 arg2


A third way would be to create a wrapper script, which would be appropriate if you needed to set multiple variables or if you needed to determine appropriate values programmatically:



#!/bin/bash
export CLASSPATH=/something
export ANOTHER_ENV_Variable=foo

exec your_fancy_program "$@"

[#41551] Saturday, October 23, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
torlim

Total Points: 408
Total Questions: 113
Total Answers: 110

Location: Estonia
Member since Wed, May 27, 2020
4 Years ago
;