I just installed openjdk 8 from brew in my Mac. However, when I am using Pair: "import com.sun.tools.javac.util.Pair;", although the IntelliJ did not report any error, but it promotes an error states that the "error: package com.sun.tools.javac.util does not exist". I remember the Java 8 contains Pair. Is openjdk 8 also contains Pair? If no, which version of openjdk contains Pair? Thanks.
Moreover, could anyone tell me if I use Oracle's java 11 to build the company's web server, do I need to pay? How will they know the purpose I use java? Will they monitor the computer? Thx!
Asked
Active
Viewed 3,734 times
2

fredpan
- 47
- 1
- 10
-
1@RobbyCornelissen there's a difference between `sun.*` and `com.sun` packages, the latter being "official sun classes" and not internal ones. But since Sun is gone, I wouldn't touch those classes either. Especially for something as trivial as a `Pair` class. – Kayaman Oct 04 '19 at 07:02
-
@Kayaman True, but the point remains the same: neither are part of the "official, supported, public interface", hence not portable. – Robby Cornelissen Oct 04 '19 at 07:05
-
You could go with the JavaFX [`Pair`](https://docs.oracle.com/javafx/2/api/javafx/util/Pair.html). On the other hand: it should be trivial to implement your own `Pair` class. (Don't forget `equals()` and `hashCode()` if you do.) – Robby Cornelissen Oct 04 '19 at 07:07
-
@RobbyCornelissen Link is irrelevant. It is explicitly and only about `sun.*` packages. There are numerous `com.sun.*` packages that are part of the JDK API, for example all the LDAP providers. However this particular package probably isn't one of them. – user207421 Oct 04 '19 at 07:40
-
Yes, it seems like I only have two options: either implement the Pair by my own or update java to java9 to have JavaFX.... Do you guys know should I pay for the license if I use java9+ to run the company's web server? – fredpan Oct 04 '19 at 14:29
1 Answers
2
You can find JDK sources here:
https://hg.openjdk.java.net/jdk/jdk13/
as far as I can tell, it's still there:
> find . -name "Pair.java" | grep javac
./src/jdk.compiler/share/classes/com/sun/tools/javac/util/Pair.java
It looks like your env related issue.
It also works perfectly fine with Java 1.8
adoptopenjdk
Default download from: https://adoptopenjdk.net
Amazon Corretto
Default download from: https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/what-is-corretto-8.html

Oo.oO
- 12,464
- 3
- 23
- 45
-
Interesting... I used brew to install the java, it's adoptopenjdk8. Which version of jdk you used? – fredpan Oct 04 '19 at 14:27
-
I am using default download from adopt and Amazon. Works perfectly fine. I am, in general, little bit sceptical about `brew` and I prefer to download packages directly from the vendor - if available. This is why I prefer installing `JDK` directly from the release page of the developer. – Oo.oO Oct 04 '19 at 15:59
-
I tried to find library which provide the `Pair` class, then intelliJ import `com.sun.tools.javac.util.Pair` for me. Is this class standard in Java? I want to use an official one. – NeoZoom.lua Jan 01 '21 at 20:51