How to set Java classpath in Linux? - linux

I downloaded apache-log4j-1.2.16.zip and unziped it. I then renamed it as LOG4J_HOME and placed it in /home/appnetix folder which is my folder. I tried setting the classpath in the terminal using the following command :
[appnetix#Sanjeev ~]$ set classpath=%path%;LOG4J_HOME/log4j-1.2.16.jar;
That returned:
bash: LOG4J_HOME/log4j-1.2.16.jar: Permission denied
I tried doing this:
[appnetix#Sanjeev ~]$ set classpath=%path%;//home/appnetix/LOG4J_HOME/log4j-1.2.16.jar;
But I got this:
bash: //home/appnetix/LOG4J_HOME/log4j-1.2.16.jar: Permission denied
Please help, I'm new in Linux (one month).

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.

Can you provide some more details like which linux you are using?
Are you loged in as root?
On linux you have to run export CLASSPATH = %path%;LOG4J_HOME/og4j-1.2.16.jar
If you want it permanent then you can add above lines in ~/.bashrc file.

Related

Netbeans 12 on Windows won't let me connect Tomcat

No matter which tutorial I follow, I am unable to get apache-tomcat-8.0.9 to work with Netbeans 12. The IDE keeps showing the error message The specified Server Location (Catalina Home) folder is not valid. I'm using jdk-14.0.1 and apache-ant-1.9.15.
The error:
My Catalina home directory C:\Program Files\apache-tomcat-8.0.9
Perhaps this error testing tomcat from the command line has some clues?
Based on the last link from the question try this:
In file nbproject/project.properties try to change this line (it may contains other path)
endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath}
to this:
endorsed.classpath=
I had the same problem and I fixed it by created CATALINA_HOME environment variable. For creating CATALINA_HOME in environment variable specify the path of catalina.bat file in tomcat folder installation without bin folder.
Ex: if you have catalina.bat in C:\Program Files\Apache\Tomcat\bin\catalina.bat, then specify in CATALINA_HOME just C:\Program Files\Apache\Tomcat as path.
I solved it in this way:
Go to the folder of Tomcat and enter, the system tells me that I don't have rigths, and if I want enter? I select yes. The system displays the content of the folder. I try again to conect netbeas with tomcat and now it works.

PATH variable not function for hadoop

I installed hadoop in the following path,
/home/myname/hadoop-2.7.2
/home/myname/hadoop-2.7.2/bin/hadoop
contains the executable file "hadoop"
Now, I set my $PATH variable in .bashrc, and I did a echo $PATH, I get
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:
/home/myname/hadoop-2.7.2/:
/home/myname/hadoop-2.7.2/bin:
/home/myname/hadoop-2.7.2/sbin
i did some formatting here. When I run bin/hadoop, i get "No such file or directory", but when I run hadoop, i get the expected result.
Not sure what I did wrong here
Thats because hadoop as you declared in your PATH variable is not on the bin directory but here :
/home/myname/hadoop-2.7.2/bin/hadoop
so to run bin/hadoop you'll have to be in /home/myname/hadoop-2.7.2 directory.
the hadoop command is working for you thanks to your declaration in the PATH variable
If you want to make the command available for all users consider moving the folder to /opt for example.
and if using debian or a debian based distro take a look at this command
http://linux.die.net/man/8/update-alternatives
Im confused as what you want to achieve though. Since when you run hadoop you get to the expected result.

Ubuntu: hadoop command not found

I am trying to check my installation of hadoop. I did create the environment variables and when I call printenv, I do see my HADOOP_HOME and PATH variables printed and correct (home/hadoop and HADOOP_HOME/bin respectively).
If I go to home/hadoop in the terminal and call ls, I see the hadoop file there. If I try to run it by calling hadoop, it still tells me command not found.
First day on Linux, so there may be a stupid answer to this problem.
Your current working directory is probably not part of your path.
That is default on linux systems.
If you are in the same directory, where your hadoop file is, run that command with an relative path, like: ./hadoop
HOME DIRECTORY:
/home/hadoop is a home directory created by linux similar to Document and settings in windows.
Open your terminal and type:
ls -l /home/hadoop
Post your result for this command: ls -l /home/hadoop
SETTING GLOBAL PATH:
Go to /home/hadoop and open .bashrc in text editor.
Add these lines at the end:
export HADOOP_HOME=/path/to/your/hadoop/installation/folder
export PATH=$PATH:$HADOOP_HOME/bin
Save and exit. Now type, this in your teminal:
echo $PATH
echo $HADOOP_HOME
If these commands shows correct directories, try hadoop command. It should work.
Post your result for these command: echo $PATH and echo $HADOOP_HOME
Go to Hadoop-x.x.x/bin folder
check for hadoop folder there
run ./hadoop version
You must run “hadoop version” command.
If the hadoop setup is fine, then you should see the following result:
Hadoop 2.4.1
Subversion https://svn.apache.org/repos/asf/hadoop/common -r 1529768
Compiled by hortonmu on 2013-10-07T06:28Z
Compiled with protoc 2.5.0
From source with checksum 79e53ce7994d1628b240f09af91e1af4
For installation related guide you can refer here:
Hadoop Environment Setup
Link to my quora answer https://qr.ae/TWngHN
Hope this helps.
Thanks
Enter which hadoop in your terminal. If you see a path as an output, hadoop is set in PATH of your system. If you get something similar to this,
usr/bin/which: no hadoop in (/usr/local/hadoop.... you might not have setup everything properly. Modify the /etc/bash.bashrc with
export HADOOP_HOME = /path/to/hadoop/folder and add it to PATH using export PATH=$PATH:HADOOP_HOME/bin
You may be editing the wrong ~/.bashrc file.
Open terminal and run sudo gedit ~/.bashrc and edit these command
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
Note: You must not use sudo gedit ~/.bashrc.sh these both work differently on newer OS

Determination and CLASSPATH installation in LINUX

Determination and CLASSPATH installation in LINUX
Excuse for a silly question (I ask to treat with understanding, I in linux the beginner and replenish knowledge as required) but how to define CLASSPATH in LINUX and where it is set. I tried to execute a command
root#one: echo $CLASSPATH
but in reply gave out only blank line.
okay so in order to set the classpath
//to temporarly set the classpath use export CLASSPATH=someclass path
open your bashrc file in nano editor(default provided editor)
type nano ./.bashrc
and type the class as mentioned below
export PATH=${PATH}:/usr/java/jdk1.5.0_07/bin
version may differ of your java
heres a link that may help you
TRY THIS LINK

running groovy script from any user directory on linux

I've put together a utility script in groovy and would like to run it in any directory as needed without having to specify full path to it. As in $> groovy myScript.groovy
I've added the path to it's parent directory to PATH in .profile, sourced it, but keep gettig 'command not found' error. Any idea where to look for the problem, conceptually speaking?
Where things are:
First line of my PostBuilder.groovy script: #!/usr/bin/env groovy`
PATH in .profile: export PATH=$PATH:/home/me/work/web/MyProject/public_html
The error I'm getting now trying to execute the script in my home directory:
Caught: java.io.FileNotFoundException: /home/me/PostBuilder.groovy (/home/me/PostBuilder.groovy)
FYI, my Groovy/Grails set up works just fine so I'm thinking installation of groovy itself is ok.
It's more likely what you really want is to:
Add the path the script is in to your PATH environment variable, and
Make it executable via chmod u+x, and
Shebang it with #!/usr/bin/env groovy (or your equivalent).
Add the path to groovy/bin to your PATH. Then you can run groovy, but you'd still need to be in the directory of your .groovy script, or supply full path, to execute.

Resources