-
Notifications
You must be signed in to change notification settings - Fork 475
added JAVA_HOME environment variable #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think this should be I just ran this test program against all the combinations: public class Test {
public static void main(String... argz) {
System.out.println(System.getProperty("java.home"));
}
} With that file as Test.java, I did the following:
This was the output:
|
Based on this the path is different for JDK and JRE |
Perhaps you're right that Looking at Tomcat's |
ok so there is a difference between IMHO relying on Or we could simply define both to cover more use cases |
I don't think that |
As I said I'm not very familiar with JAVA so I'm not sure what is more common or where the differences are. |
I'm actually not sure. What was the use case you were trying to address by adding |
I described my my situation in #27 |
I just noticed that
cf. The version in the
So if it makes sense to add LGTM (sorta) |
So so should I update my PR or should we consider |
I think you should update your PR, but I'm personally +0 on this change. Perhaps just documenting |
I think having |
ok I've updated the PR |
LGTM, @tianon? |
I'm also totally +0 on whether this should be a code change or a docs change, especially since it's a legacy thing. What I'm definitely -1 on is having it be hard-coded in each Dockerfile like this with no verification that it's correct. I think what I'd be more comfortable with is having some way to verify that the value is correct after our install, and having the whole build bail if it's not: ENV JAVA_VERSION 6b34
ENV JAVA_DEBIAN_VERSION 6b34-1.13.6-1~deb7u1
RUN apt-get update && apt-get install -y openjdk-6-jdk="$JAVA_DEBIAN_VERSION" && rm -rf /var/lib/apt/lists/*
ENV JAVA_HOME /usr/lib/jvm/java-6-openjdk-amd64
RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ] Example: $ for v in 6 7 8; do for a in $v-jre $v-jdk; do { echo "FROM java:$a"; echo "ENV JAVA_HOME /usr/lib/jvm/java-$v-openjdk-amd64"; echo 'RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ]'; } | docker build -; done; done
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM java:6-jre
---> bf4469de640a
Step 1 : ENV JAVA_HOME /usr/lib/jvm/java-6-openjdk-amd64
---> Running in 1a03bea755dc
---> 124dbafcd548
Removing intermediate container 1a03bea755dc
Step 2 : RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ]
---> Running in f92e985520a5
+ which java
+ readlink -f /usr/bin/java
+ dirname /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
+ readlink -f /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/../..
+ [ /usr/lib/jvm/java-6-openjdk-amd64 = /usr/lib/jvm/java-6-openjdk-amd64 ]
---> a3c08eeff205
Removing intermediate container f92e985520a5
Successfully built a3c08eeff205
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM java:6-jdk
---> ac9411624983
Step 1 : ENV JAVA_HOME /usr/lib/jvm/java-6-openjdk-amd64
---> Running in 875657e67ecd
---> 1af4b405173f
Removing intermediate container 875657e67ecd
Step 2 : RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ]
---> Running in f98017de94cc
+ which java
+ readlink -f /usr/bin/java
+ dirname /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
+ readlink -f /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/../..
+ [ /usr/lib/jvm/java-6-openjdk-amd64 = /usr/lib/jvm/java-6-openjdk-amd64 ]
---> 5b46b59fa73d
Removing intermediate container f98017de94cc
Successfully built 5b46b59fa73d
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM java:7-jre
---> d0b904b99306
Step 1 : ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
---> Running in 185d27736972
---> d0d84a069215
Removing intermediate container 185d27736972
Step 2 : RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ]
---> Running in 08526a5df2bb
+ which java
+ readlink -f /usr/bin/java
+ dirname /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
+ readlink -f /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/../..
+ [ /usr/lib/jvm/java-7-openjdk-amd64 = /usr/lib/jvm/java-7-openjdk-amd64 ]
---> d28718162603
Removing intermediate container 08526a5df2bb
Successfully built d28718162603
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM java:7-jdk
---> 513c90950366
Step 1 : ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
---> Running in ad67dbc6013b
---> e893fcd7d191
Removing intermediate container ad67dbc6013b
Step 2 : RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ]
---> Running in 4cdb109cf11f
+ which java
+ readlink -f /usr/bin/java
+ dirname /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
+ readlink -f /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/../..
+ [ /usr/lib/jvm/java-7-openjdk-amd64 = /usr/lib/jvm/java-7-openjdk-amd64 ]
---> b906c66c2670
Removing intermediate container 4cdb109cf11f
Successfully built b906c66c2670
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM java:8-jre
---> 7aaf9421464d
Step 1 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
---> Running in 9547bbd478ef
---> 43cca47c38c6
Removing intermediate container 9547bbd478ef
Step 2 : RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ]
---> Running in 326a591e149a
+ which java
+ readlink -f /usr/bin/java
+ dirname /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
+ readlink -f /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/../..
+ [ /usr/lib/jvm/java-8-openjdk-amd64 = /usr/lib/jvm/java-8-openjdk-amd64 ]
---> 8e6183c64018
Removing intermediate container 326a591e149a
Successfully built 8e6183c64018
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM java:8-jdk
---> ed632caf877b
Step 1 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
---> Running in 4f291a67a9b0
---> a6193c9085a5
Removing intermediate container 4f291a67a9b0
Step 2 : RUN set -x && [ "$JAVA_HOME" = "$(readlink -f "$(dirname "$(readlink -f "$(which java)")")/../..")" ]
---> Running in b552769a249a
+ which java
+ readlink -f /usr/bin/java
+ dirname /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
+ readlink -f /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/../..
+ [ /usr/lib/jvm/java-8-openjdk-amd64 = /usr/lib/jvm/java-8-openjdk-amd64 ]
---> 24cfc8d56faa
Removing intermediate container b552769a249a
Successfully built 24cfc8d56faa |
@tianon I also thought about setting the env variable via the command you used but as the Java version itself is hardcoded it is, in my opinion, it is also ok to hardcode the path to |
@soupdiver, it seems @tianon was just adding a |
Would it be sufficient for that check to be in |
Or in a test in |
@yosifkit Oh, sorry totally overlooked that |
I am not sure where we would want it.
|
|
@@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/* | |||
|
|||
ENV JAVA_VERSION 8u40~b22 | |||
ENV JAVA_DEBIAN_VERSION 8u40~b22-2 | |||
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/usr/lib/jvm/java-8-openjdk-amd64
for openjdk-8-jre
?
Fixes #27