DEV Community

Cover image for Possible Error when we have both javac 11.0.9.1 and javac 8
Rohith V
Rohith V

Posted on

Possible Error when we have both javac 11.0.9.1 and javac 8

I usually uses Eclipse and online editors to run my java programs. But yesterday, I took my sublime editor, write a simple java program, data structure model and run the program using the javac command in command line.

javac filename.java

But first it shows I am not having javac and need to install using sudo apt ... command as shown in the screen.

I ran it and installed the javac and when I checked, it was javac 11 version. So I included the javac 8 while again installing the javac to get version 8, still the version shows 11.

So I just leave it and compiled the program. It compiled succesfully, but it couldn't run and shows a message.(1
)

So I searched for the error and found a possible fix for it.
We can use the following command to successfully compile and run the code in javac 8.
javac -target 8 -source 8 filename.java
java filename

But it shows a warning which I am not that much familiar and not that much understandable.
The warning is as follows:
warning: [options] bootstrap class path not set in conjunction with -source 8
1 warning

I don't know what exactly its saying but I got my code compiled and run successfully.
So the above command is one of the fix that can be used to fix the above error, if anyone faces it.

More discussion about the warning is most welcome and I am very much excited to know what's exactly the warning is.

Thank You

Discussion (1)

Collapse
ndrone profile image
Nicholas Drone

You installed 2 versions so which one is being used? Type java --version to find that out. Also what other jars are being used? Do you have a screenshot of the imoorts? I usually get errors like this when using older versions of jars that depend on specific java versions. Or rather specify what versions of java it can work in.