Alapan Kuila
Alapan Kuila

Reputation: 159

Compiling java program in linux

I have installed openjdk-9-jdk-headless. When I am checking version of the Java then also it gives the appropriate answer. But when I'm compiling any Java program with "$ javac Find.java " it gives:

The program 'javac' can be found in the following packages:
 * default-jdk
 * ecj
 * gcj-5-jdk
 * openjdk-8-jdk-headless
 * gcj-4.8-jdk
 * gcj-4.9-jdk
 * openjdk-9-jdk-headless
Try: sudo apt install <selected package>

Please help how can I compile and run java program.

Upvotes: 0

Views: 1552

Answers (3)

tripleee
tripleee

Reputation: 189297

It's telling you that you do not have the Java compiler installed. It also tells you how to fix this problem.

sudo apt install openjdk-9-jdk-headless

(or one of the other packages it offers as alternatives, at your discretion).

The javac command is distinct from the java command.

Upvotes: 1

pitaside
pitaside

Reputation: 678

edit your ~/.bashrc and add this to the end JAVA_HOME=opt./../jdk/ export PATH=$PATH:$JAVA_HOME

save the ~/.bashrc source ~/.bashrc

Try to compile again

Upvotes: 0

xCodeZone
xCodeZone

Reputation: 194

Have you configured the path?

export PATH=${PATH}:{path to your jdk bin folder here}

Or use full path to javac while compiling.

Upvotes: 0

Related Questions