[MacPorts] #58098: Install openjdk8 as default JVM

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

[MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
#58098: Install openjdk8 as default JVM
-------------------------+----------------------
 Reporter:  giansalvo    |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  Normal       |  Milestone:
Component:  ports        |    Version:  2.5.4
 Keywords:               |       Port:  openjdk8
-------------------------+----------------------
 I'm trying to port a java based application (Arduino IDE) to MacPorts.
 The Arduino application is built correctly and Arduino.app get installed
 to /Applications/MacPorts folder. [[BR]]
 However when I launch Arduino.app I get "Unable to load Java Runtime
 Environment".

 I installed openjdk8 with sudo 'port install openjdk8'. [[BR]]
 I have another JVM installed that looks like the default JVM (see attached
 files):
 {{{
 $ls  /Library/Java/JavaVirtualMachines/
 jdk1.8.0_131.jdk        openjdk8
 }}}
 What is (if it's possible) the clean way to install openjdk8 as the
 default JVM?

--
Ticket URL: <https://trac.macports.org/ticket/58098>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------
Changes (by giansalvo):

 * Attachment "Schermata 2019-02-18 alle 21.35.56.png" added.


--
Ticket URL: <https://trac.macports.org/ticket/58098>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------
Changes (by giansalvo):

 * Attachment "Schermata 2019-02-18 alle 21.40.33.png" added.


--
Ticket URL: <https://trac.macports.org/ticket/58098>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by ryandesign):

 I don't know.

 My understanding is ports should use the java 1.0 portgroup to indicate
 what JDK they want.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------
Changes (by jmroot):

 * cc: breun (added)


Comment:

 Are you just wanting to get this one port to use a specified JRE? That's
 different to setting it as the default.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:2>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by breun):

 The standard way of setting your default JVM is by setting the `JAVA_HOME`
 environment variable.

 When you install the `openjdk8` port this message is displayed explaining
 this:

 {{{
 If you have more than one JDK installed you can make JDK 8 the default
 by adding the following line to your Bash shell profile (~/.bash_profile):
     export
 JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk8/Contents/Home
 }}}

 You can check the value of `JAVA_HOME` by running `echo $JAVA_HOME`. On my
 machine I get this:

 {{{
 $ echo $JAVA_HOME
 /Library/Java/JavaVirtualMachines/openjdk8/Contents/Home
 }}}

 What do you get on your machine?

 You can run `/usr/libexec/java_home -V` to get a list of all JVM's on your
 machine (as long as they're installed under
 `/Library/Java/JavaVirtualMachines`).

 Another method is using `/usr/libexec/java_home` to find a JVM matching
 the desired Java major version like this:

 {{{
 $ /usr/libexec/java_home -v 1.8
 /Library/Java/JavaVirtualMachines/openjdk8/Contents/Home
 }}}

 You could use that command in your Bash profile like this:

 {{{
 export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
 }}}

 Although I prefer to set `JAVA_HOME` to an explicit location myself.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:3>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------
Changes (by giansalvo):

 * Attachment "Schermata 2019-02-19 alle 18.01.56.png" added.


--
Ticket URL: <https://trac.macports.org/ticket/58098>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by giansalvo):

 Replying to [comment:3 breun]:
 > The standard way of setting your default JVM is by setting the
 `JAVA_HOME` environment variable.
 >
 > When you install the `openjdk8` port this message is displayed
 explaining this:
 >
 > {{{
 > If you have more than one JDK installed you can make JDK 8 the default
 > by adding the following line to your Bash shell profile
 (~/.bash_profile):
 >     export
 JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk8/Contents/Home
 > }}}
 >
 Yes I know. This is true for java applications that you launch from the
 terminal/shell. But I need to "link" the JVM with a macOS bundled java
 application (Arduino.app in the `/Applications` folder). As far as I could
 see the `JAVA_HOME` shell variable set in the Bash profile configuration
 file doesn't affect the .app application.

 Furthermore as you can see from the third attached image, the .app file
 contains already the entire `openjdk8` JRE.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by giansalvo):

 Replying to [comment:2 jmroot]:
 > Are you just wanting to get this one port to use a specified JRE? That's
 different to setting it as the default.

 I actually would like to link this specific port to openjdk8 JRE (which is
 already contained in the .app file). At worst I'd like to try setting it
 for the all system.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:5>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by breun):

 If the app already contains an entire JRE, then I think it won't be
 necessary to have the `openjdk8` port installed. I'm not very familiar
 with macOS GUI apps that use Java, but I guess the .app must contain some
 kind of start script that starts the `java` process with the correct
 arguments. Maybe you can take a look at the package contents of another
 macOS GUI app on how to do this. Dealing with the `JAVA_HOME` environment
 variable indeed shouldn't be necessary in this case.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:6>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by kencu):

 Alternatively there is a way to set environment variables using the
 `plist` file in the bundle that might be of use for this. You could set it
 to a specific `JAVA_HOME` perhaps.

 <https://superuser.com/questions/476752/setting-environment-variables-in-
 os-x-for-gui-applications>

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:7>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by giansalvo):

 Replying to [comment:6 breun]:
 > If the app already contains an entire JRE, then I think it won't be
 necessary to have the `openjdk8` port installed.
 The app was built WITH `openjdk8` and should contain it but somehow it
 isn't recognized or something like that.

 Replying to [comment:6 breun]:
 > I'm not very familiar with macOS GUI apps that use Java, but I guess the
 .app must contain some kind of start script that starts the `java` process
 with the correct arguments (using the `java` binary from the included
 JRE). Maybe you can take a look at the package contents of another macOS
 GUI app on how to do this.
 It's exactly what I thought but I couldn't find any macOS GUI Java app
 already ported in MacPorts. Do you know any?

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:8>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------
Changes (by giansalvo):

 * Attachment "Info-openjdk.plist" added.

 this is Info.plist file found inside the macOS app bundle

--
Ticket URL: <https://trac.macports.org/ticket/58098>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by breun):

 I'm not familiar with macOS GUI Java apps, but that `Info.plist` contains
 references to `$JVM_RUNTIME`. I don't know if that has a value and if so,
 where it would come from. The screen shot you attached also shows the
 `openjdk8` dir to be in `Contents/PlugIns/openjdk8`, while the plist
 references `$JVM_RUNTIME/Contents/Java` (I don't know what's in there). If
 the JRE really is contained in the .app, then I don't think you'd need an
 environment variable like `$JVM_RUNTIME`, but should just be able to point
 to the Java directory inside the .app directly. I don't really think this
 is really a MacPorts question actually, maybe a place with people who know
 how to create a macOS .app with a JRE inside will be able to help you
 better.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:9>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by giansalvo):

 I was able to fix the problem using {{{/usr/libexec/java_home}}} to set
 {{{JAVA_HOME}}} environment variable.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:10>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #58098: Install openjdk8 as default JVM

MacPorts
In reply to this post by MacPorts
#58098: Install openjdk8 as default JVM
--------------------------+--------------------
  Reporter:  giansalvo    |      Owner:  (none)
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.5.4
Resolution:               |   Keywords:
      Port:  openjdk8     |
--------------------------+--------------------

Comment (by breun):

 That method will not use the included JRE though, because
 `/usr/libexec/java_home` won't find that, so then users will need to have
 a separate Java installation.I guess it should be possible to point
 `JAVA_HOME` to the included JRE instead.

--
Ticket URL: <https://trac.macports.org/ticket/58098#comment:11>
MacPorts <https://www.macports.org/>
Ports system for macOS