Intellij IDEA setup on OS X - java

What's the accepted procedure and paths to configure jdk and global library source code for Intellij IDEA on OS X?

As of the latest releases:
Java for Mac OS X 10.6 Update 3
Java for Mac OS X 10.5 Update 8
Apple has moved things around a bit.
To quote the Apple Java guy on the java-dev mailing list:
System JVMs live under /System/Library/...
These JVMs are only provided by Apple, and there is only 1 major
platform version at a time.
The one version is always upgraded, and only by Apple Software Updates.
It should always be GM version, that developers can revert back to, despite
any developer previews or 3rd party
JVMs they have installed.
Like everything else in /System, it's owned by root r-x, so don't mess
with it!
Developer JVMs live under /Library/Java/JavaVirtualMachines
Apple Java Developer Previews install under /Library.
The Developer .jdk bundles contain everything a developer could need
(src.jar, docs.jar, etc), but are too
big to ship to the tens of millions of
Mac customers.
3rd party JVMs should install here.
Developers working on the JVM itself can use
~/Library/Java/JavaVirtualMachines
It's handy to symlink to your current build product from this
directory, and not impact other users
Java IDEs should probably bias to using /Library or ~/Library detected
JVMs, but should be able to fallback
to using /System/Library JVMs if
that's the only one installed (but
don't expect src or JavaDoc).
This allows Java developers the
maximum flexibility to install
multiple version of the JVM to regress
bugs and even develop a JVM on the Mac
themselves. It also ensures that all
Mac customers have one safe, slim,
secure version of the JVM, and that we
don't endlessly eat their disk space
every time we Software Update them a
JVM.
So, instead of pointing Intellij at /System/Library/Frameworks/JavaVM.framework, you should point to a JDK in either /Library/Java/JavaVirtualMachines or /System/Library/Java/JavaVirtualMachines

In the 'Project Settings' window, go to 'JDKs' section that you see under'Platform Settings'. Click the little plus sign and choose 'JSDK'. A file chooser should open in the /System/Library/Frameworks/JavaVM.framework/Versions directory. If not then just navigate to it. There you can choose the version you would like to add.

IntelliJ should detect your installed JDK's, as they are in a standard location that Apple provides. If you want source code for the JDK, you can download that from Apple as well. Sign up for a free ADC account and then you can get access.
For global libraries, I've been enjoying the Maven integration in the recent release. It alleviates the need to setup global libraries by pulling things from the Maven repository. It will download source and javadoc jars as well.

the JDK that comes with osx doens't include the source. you need to log into the apple developer site with your apple account to find the developer version of the SDK which includes src.jar.
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.1.3.3.1

The post from intellij support page explains how to configure the JDK which Intellij uses to run itself.
https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under

Related

How to run java program using Oracle JDK 17, if Oracle JDK 17 does not come with JRE [duplicate]

This question already has answers here:
How can I get Java 11 run-time environment working since there is no more JRE 11 for download?
(4 answers)
Closed 3 years ago.
We are planning to migrate our Java 8 project to use Java 11. But I noticed that Java 11 doesn't have a JRE folder.
In Java 9 and Java 10, folder structures are changed i.e. java\jdk1.x or java\jre1.x, where x is Java 9 or 10.
But in Java 11, I am getting only one folder, i.e. java\jdk-11. How will my client use my application without jre?
What I understood is that Java 11 is enforcing to modularize our application, and using jlink is needed to create our own jre to run the application in client.
Is my understanding correct?
For 20 years, the JDK shipped with a JRE which was just a subset of its functionality installed in a different directory on your system.
In fact, it shipped with TWO identical JREs, one installed inside the JDK installation directory and one outside it.
This has always puzzled me as it's a complete waste of effort on the part of the maintainers to make this so, and a complete waste of disk space on the computer you install it on, as that JRE just duplicates some of the things the JDK can do already.
Finally, with Java 11, Oracle and the OpenJDK team decided to end this silliness and just distribute a single thing, the JDK.
This JDK when installed is actually smaller on your hard disk than the old JRE alone used to be, removing even the somewhat valid argument that you'd want a separate JRE for devices with limited disk space, an argument that never explained why 2 JREs would be installed with a single JDK in the first place but was made to justify the need for a JRE as a stripped down runtime environment for the JDK.
Ergo, there is no need for a separate JRE, and there hasn't been one for a long time, let alone for including and forcibly installing it as part of the JDK installation.
And no, you don't need to create your own JRE. Just install the OpenJDK on the client machines and make sure you add the $JAVA_HOME/bin to the system path, just as you had to do with old JREs.
And oh, strip the Windows directory tree of any java*.exe files which some versions of the old JRE installer were wont to place there, as well as the system path which also had some weird entries added by some JRE installers.
tl;dr
How will my client use my application without jre?
➥ Bundle a Java implementation within your Java-based app.
Learn about:
Java Platform Module System
jlink (JEP 282)
jpackage (JEP 343)
Details
What I understood is that Java 11 is enforcing to modularize our application
No, modularization is not required, strictly speaking. Most existing apps can run as-is in Java 11. You can continue to develop in Java 11 without modularizing your code. But in your case, for a GUI desktop or mobile app, then you need to package a JVM within your app. Modularizing and using jlink tooling is probably the best way to go about that. In contrast a server-side Servlet-based app or Microservices server need not yet modularize, though likely a good idea to do so eventually.
I noticed that Java 11 doesn't have a JRE folder.
Oracle no longer intends for end-users to be installing a JRE or a JDK. Java Applets in a browser and Java Web Start app delivery are both being phased out, leaving the end-user with no need for a JRE. Java-based apps are expected to bundle their own Java implementation. The only folks consciously installing a JDK will be developers & server-side sysadmins.
Some folks are disappointed to see the passing of the Java Everywhere dream. And they may be annoyed to have to make a build of their app for every host OS (macOS, Linux, Windows, etc.). On the other hand, some developers are happy to be bundling a Java implementation (now smaller than ever) with their app, as that eliminates the hassle for the end-user to download-install-update a system-wide Java implementation. Also eliminates wrestling with corporate IT departments to install Java on users’ PCs. And bundling Java with app simplifies testing and support, as you know and control exactly what version and distribution of Java is involved. By the way, this bundling-Java-with-app is not exactly new: It has been supported by Apple for many years in the macOS & iOS app stores.
Important:
Understand clearly the nature of the OpenJDK project, as explained in Wikipedia
Read this white paper by Oracle of 2018-03, Java Client Roadmap Update
Read the white paper Java Is Still Free, authored by key members of the Java community.
Here is a flowchart diagram that may help you finding and deciding amongst the various vendors providing a Java 11 implementation.
Look at the AdoptOpenJDK project website to download the latest JRE and JDK.
I have used their nightly builds to work around the problem of missing JRE in JDK package. Just unpack JRE into JDK folder and this is going to be it.

Eclipse IDE on Mac?

I'm trying to get Eclipse 4.5.2 running on Macs with OS X 10.10.5 and Oracle Java 8u73 I got to the point where trying to start Eclipse results in
The JVM shared library "$JAVA_HOME/bin../jre/lib/server/libjvm.dylib" does not contain the JNI_CreateJavaVM symbol.
Googling this returns a whole bunch of suggestions, none of which work. Some say you absolutely MUST have the JDK (I'm using the JRE). Others emphatically say the JRE is all you need. Some suggest editing an Info.plist or another, with people responding "Yeah that worked!" right along with "That didn't work"
How do I get past this message?
You need the JDK because, well, to be honest Apple hates Java and has done a thorough job of screwing up what used to be the best OS for Java development.
The "you need legacy Java" message was from OS X, not Eclipse. The advice to download and install it is bad advice, but sadly nothing that Eclipse can remedy. Installing "legacy Java" just reverts your system to a VERY outdated JRE and renders much Java-based software, including Eclipse, broken.
Eclipse requires Java 7 or above (this year's release of Eclipse packages in June will require Java 8 ), so the best thing is to download JDK 1.8 (not just the JRE), install that, then point your eclipse.ini file to it's exact location per the instructions at the eclipse.ini wiki page.
Oracle JDK download links change often, so it's best to Google for "JDK 8 download" and you'll find it. Here's the page as it stands at the time I'm writing this.
[quoted from this Eclipse forums message]

I make my executable jar in exe format,but i want to add jre with this

I make my executable jar in exe format, but I want to add JRE with this because if JRE is not present in their machine, they can use it with this included JRE.
But I do not want to install this JRE in their machine. This JRE is only used by this application only. It will just like game or other application. I use launch4j to make jar to exe but i did not find any option from where it can attach JRE and it has no option from where I can link my jar dynamically.
How do I achieve that?
If there is other free installer then mention it, and please give the procedure with example.
Since it has been established that your app. has a GUI, I will suggest Java Web Start as the answer.
But I do not want to install this JRE in their machine.
That is not a sensible requirement. The user might already have a usable JRE installed, if they don't they probably also don't want every Java based application to be installing its own 'private' JRE.
Oracle's deployJava.js can do the checking, and help guide the user through the steps of installing (which basically comes down to click 'OK' when prompted).
I make my executable jar in exe format,..
If you only intend to support Windows, what is the attraction of coding in Java? JWS supports any platform for which Java is available. That brings a lot more potential customers for the app.
I want to use free installer.
JWS is entirely free. Just like the JRE.
..please give the procedure with example.
Do you run an IDE? If not, do you otherwise have Ant installed? If that is a yes to either one, check out my small JNLP API examples. Each comes with complete source and a build file (an Ant build.xml).
Within a couple of keystrokes & a few moments, you can see the app. installed and launched on your desktop. For the end user, it is even simpler. Just click a link in a web page, and it all happens automatically (possibly with a security prompt - for the protection of the user).
I like JSmooth. You can give it a try here:
http://jsmooth.sourceforge.net/features.php
Flexible automatic Java VM detection
Detects the location of any Sun JVM installed. The wrappers use
several strategies to detect all the JVM available on a computer,
using windows registry, environment variables, windows path.
Detects
and uses Microsoft's JView (for 1.0 and 1.1 Java applications), if
available.
The JVM search sequence is fully customizable using the
GUI. You can force the executable to search in the path first, and in
the registry last, or in JAVA_HOME first. We have all the flavours!
Sometimes it's more convenient to bundle a JRE with your application.
JSmooth can deal with that too, you just need to define in which
folder the JRE is expected. It falls back nicely to a standard JVM
search if the JRE is not where it should be.
Specify which versions of
the JVM are compatible with your software. You can set a minimum
version, but also a maximum JVM version.
Documentation: http://jsmooth.sourceforge.net/docs/jsmooth-doc.html
Take a look at launch4j.
I had to use it, and it worked out very well.
You can set a minimum version of a needed JRE, bundle a JRE, or if a JRE is not found (and not bundled) the launcher may lead the user to a download location of an appropriate JRE.
There are various further features launch4j offers, and as opposed to another suggestion here, launch4j is activly developed
http://launch4j.sourceforge.net/

JDK documentation in IntelliJ IDEA on Mac OS X

I'd like to know how to setup IntelliJ to point to the JDK documentation so the documentation popups that display during code completion will show me what the function I'm looking at is going to do. For some reason IntelliJ isn't able to find the JavaDocs by default.
I'm also not 100% sure that the documentation is installed with the JDK that's installed with the OS. I don't see them in /System/Library/Frameworks/JavaVM.framework/ but I may be looking in the wrong place. If it's not included, I'd also like to know what needs to be downloaded and where it needs to be installed to get the JavaDocs for the JDK to show up in IntelliJ.
I had to combine the responses I got to this point and add a few extra details so I'm answering my own question.
Search for "Java developer" from Downloads for Apple Developers
Download and install "Java for Mac OS X 10.6 Update 9 Developer Package" (or later).
In IntelliJ, open File -> Project Structure.
Click on "SDKs" under "Platform Settings".
Add the following paths under the "Documentation Paths" tab (the paths may be different based on which JDK you're using):
/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/docs.jar!/docs/api
/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/appledocs.jar!/appledoc/api
Add the following path under the Sourcepath tab:
/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar!/src
Thanks, #Yishai for the download location and #Gareth Davis for the location of the documentation after installing.
Update for 10.7/10.8 [Mountain] Lion:
Steps are the same except for these changes:
In step 2, download "Java for OS X 2012-005 Developer Package" (or later).
Use these paths instead in step 5.
/Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/docs.jar!/docs/api
/Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/appledocs.jar!/appledoc/api
Use these paths instead in step 7.
/Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/src.jar!/src
Quick (and dirty?) solution: Point IntelliJ to http://download.oracle.com/javase/6/docs/api/
have you installed the Apple Java Developer package?
It provides src.jar and docs.jar in /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home
Note this is since update 3. If these are present Intellij will just find them, or at least mine did.
details are in the Java update release notes
This should tell you what you need to know: Get local copies of Mac OS X Java source code and Javadoc – Concord Consortium wiki.
That page recommends going to https://connect.apple.com and downloading and installing “Java for Mac OS X 10.5 Update 2 Developer Documentation (Disk Image)” or the equivalent newer release. It describes a few ways to view the documentation, based on the Java jar file being located at a path like this:
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/src.jar

Use BlackBerry JRE 5.0.0 or previous on MacOS

I have my Windows work computer set up with JDE 5, but the plugin for the Mac OSX Eclipse on my home computer is JDE 6 and I can't seem to find a source to download it from.
I found a blog post about MacOS BlackBerry development, but it is from before the official MacOS plugin was released. Anything new on this front?
Just in case it saves anyone else wasting half a day, "FYI: Blackberry JDE 4.6 setup on Mac" on the BlackBerry support forums explains how to use the older Blackberry JREs with Eclipse on the Mac.
Were you still looking for an answer to this question? RIM has released the update for the Mac Eclipse v 1.1.2 Plugin. You have to go to "Help > Install New Software ..." and type the url: http://www.blackberry.com/go/eclipseUpdate/3.5/java . It should come up with options for the BlackBerry Java Plug-in Category. Clicking the arrow will reveal the other OS component packs (4.5 - 6.0). Install these (will take a while).
After this, go to the folder where your Eclipse plugins are located. You'll see the folders for the component packs (e.g. "net.rim.ejde.componentpack"). Copy the net.../components/bin folder from the 6.0 component pack to the other versions' components folder (backup the old one first).
In the components folder, there will be a BlackBerry.ee file. Copy the one from the 6.0 component pack into the other versions' components folder (again, backup the original). Open the new .ee file in a WYSIWYG text editor and change the version information to be accurate to the current component pack's version (e.g. 6.0.0.29 changes to 5.0.0.25).
In Eclipse, you need to add a system library. Open the Preferences and go to the Java > Installed JREs menu and click "Add...". When the window pops up, click "BlackBerry Execution Environment VM." For definition file, this is the BlackBerry.ee file for the version of the JRE you are adding. Name the JRE appropriately (e.g. BlackBerry 5.0). Next, click "Add External JARs..." and navigate to the net.../components/lib folder. Select the net_rim_api.jar file. Click finish and you should be good to go. (Repeat for other versions as necessary).
All that's left to do is to specify the correct JRE in your project properties (Java Compiler > {Click} Installed JREs link). Then, make sure the correct version is selected. Also, make sure there is only one JRE listed in the Project Explorer (newbie lesson learned).
Hope that helps if you still needed it to.
I should also add that I'm running my simulators on Windows via Parallels.
RIM has only released an Eclipse Plugin on OS X. The JDE is Windows-only and probably will always be Windows-only (RIM is trying to phase out the JDE and is encouraging all developers to move to the Eclipse platform).
Keep in mind that the Eclipse plugin for OS X is still VERY new and still has some rough edges - I tried it out and it crashed on more than one occasion! Also, there is no simulator available on OS X yet so you'll need a physical device to deploy and test on (I think it has to be a 9800 but I could be wrong). RIM has promised a simulator on OS X but probably not for another 6 months or so.
For Eclipse 3.6 you must use this url: http://www.blackberry.com/developers/jar/3.6/java/
If after downloading have error because too much authentication error, i'm suggesting you must re-create bb developer zone account & login using it (Kind of annoying, coz at my country bandwidth is limited & after waiting 3 hour, the installation is failed).
Also, in copying file don't forget copy fledge from net.rim.ejde.componentpack6.0.0_6.0.0.30/components/. If not when i try to add the definition file JRE i got this kind of error
"Execution Environment File Property-Dee.executable must point to a valid copy offledge.exe"
Hope this is can help.
Ahh. Seems like Apple removed java 5 and below from Snow Leopard (10.6). Leopard (10.5) still supports 1.4.2 and 5.0 and 6.0. You can find them in "/Applications/Utilities/Java Preferences.app".

Categories

Resources