Ask Your Question

bash: command not found... in fedora21

asked 2015-03-25 15:14:14 -0500

Bapi gravatar image

When i want to ran a java program via terminal "bash: command not found..." error shows.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-03-26 11:00:47 -0500

At the commandline, the first word you enter is interpreted as a command. The shell will look for that command in a bunch of different places which listed in your PATH environmental variable (which is why you sometimes need to add new directories to it) or you can manually tell the shell that you want it to run what is in your current directory using ./ like ./myapp.

echo $PATH will show you which folders your shell will look in for executables. The next question is what is executable within those folders. So shell scripts, for example, can be executed just by typing ./ provided that they are marked as executable.

Java files, however, are not executable. You need an interpreter (Java!) to run them. Actually before you do that, you need to compile your java files into bytecode (not the same as machine code). To do that you use javac. javac produces a bunch of .class files that java can interpret.

So to run my file I would do this:

java HelloWorld
edit flag offensive delete link more

answered 2015-03-25 15:48:50 -0500

aeperezt gravatar image

You need to grant execution permits or run it like:


Hope it helps

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-03-25 15:14:14 -0500

Seen: 246 times

Last updated: Mar 26 '15