I think you should not put any paths that a local to your home directory in a system wide file. I would leave /etc/environment well alone, unless you provide some changes, that are necessary or beneficial to all users.
Put any changes to the CLASSPATH in your .bashrc in your home directory.
CLASSPATH=$CLASSPATH:/home/foo:/home/foo/Java_code/my_code
export CLASSPATH
This way you can source it and any newly started bash will have the settings right at once.
Answer from Mithrandir on Stack OverflowI think you should not put any paths that a local to your home directory in a system wide file. I would leave /etc/environment well alone, unless you provide some changes, that are necessary or beneficial to all users.
Put any changes to the CLASSPATH in your .bashrc in your home directory.
CLASSPATH=$CLASSPATH:/home/foo:/home/foo/Java_code/my_code
export CLASSPATH
This way you can source it and any newly started bash will have the settings right at once.
export CLASSPATH=""
or better
unset CLASSPATH
will delete an existing Classpath. There are multiple locations where you can set or unset the classpath - a missing entry will not unset it.
Videos
You have to supply the complete path after the parameter -jar. So for your example you have to call
java -jar /home/user/plantuml.jar -testdot
The $CLASSPATH is only evaluated to find additional files (classes/resources) but not the jar file defined in the command line.
export CLASSPATH="/path/to/class_or_jar1":"/path/to/class_or_jar2":"${CLASSPATH}"
export CLASSPATH=/home/appnetix/LOG4J_HOME/log4j-1.2.16.jar
or, if you already have some classpath set
export CLASSPATH=$CLASSPATH:/home/appnetix/LOG4J_HOME/log4j-1.2.16.jar
and, if also you want to include current directory
export CLASSPATH=$CLASSPATH:/home/appnetix/LOG4J_HOME/log4j-1.2.16.jar:.
You have to use ':' colon instead of ';' semicolon.
As it stands now you try to execute the jar file which has not the execute bit set, hence the Permission denied.
And the variable must be CLASSPATH not classpath.
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 "$@"
that's what happened with me.. i left empty spaces while typing.. it fixed when i removed spaces.
1) if you want to set classpath permanently then 1) find out where java is installed.. you may use " whereis java " openjdk-7/6 is in /usr/lib/jvm/.....
2) we need to set up CLASSPATH in /etc/environment
sudo gedit /etc/environment
3) add the following likes .. ( DONT LEAVE ANY SPACES WHILE TYPING)(customize according to your java version and installation) (this home path is for open jdk 7)
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386/bin"
export JAVA_HOME
CLASSPATH=".:/usr/lib/jvm/java-7-openjdk-i386/lib:/home/laptop/Desktop/a2"
export CLASSPATH
separate directory by ":"