0

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.

1
  • Ensure that your javac binary is on the path. edit your path variable $PATH:/opt./../jdk/bin Commented Sep 9, 2016 at 5:06

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Have you configured the path?

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

Or use full path to javac while compiling.

Comments

0

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

2 Comments

Wouldn't be /etc/profile.d/<script> a better place?
i wont prefer that but u can also put inside the /etc/environment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.