Factsheet
[workflow] Best setup for developing in Java on linux?
I use Ubuntu/Mint with Oracle's JDK. IntelliJ for the IDE. There is both a free and pay version of IntelliJ, but I find it to be faster, cleaner GUI, and has fewer bugs/really annoying quirks than Eclipse.
More on reddit.comShouldn't Java be a better choice for Linux scripting compared to bash or python or perl?
"Unable to locate the Java runtime" error on launch. Will give gold.
Vim for Java?
Editing without an IDE could be a bit paiful at first sight, maybe you can have a look at this to setup some help http://www.averywagar.com/post/configuring-vim-for-java-development
More on reddit.comWhat is Java command in Linux?
How to install Java packages in Linux?
What is Knowledge Pass, and how does it work?
Videos
I know programming and did a bit of Java before. Now I want to do serious development (for academic purposes, so not that large scale).
What's the best setup for Java on linux (ubuntu)? I remember from back in the days 3 or 4 flavours of Java co-existing on my system, and things not working terribly well.
Which flavour should I go for if I want to use Java professionally? How do I install it and make sure it's the main one used?
Is Eclipse still the best thing in town? (never liked it, always used gedit, but I guess I'll have to change my ways)
Would I use the same setup for writing smartphone apps? (as a hobby, not part of the job)
Thank you all in advance!
Update: Thanks a lot for all the detailed answers!
So it looks like the java situation got a bit better on linux, and openJDK is a solid version. Good to know.
IDE-wise: many votes for eclipse, but intelliJ and netbeans are good alternatives. I'll give each a go.
Android dev: Eclipse is preferable.
Also important point that is shared by many: get java from the repositories,but the IDEs directly from the original websites (easier to configure, up-to-date and less bloated).
I use Ubuntu/Mint with Oracle's JDK. IntelliJ for the IDE. There is both a free and pay version of IntelliJ, but I find it to be faster, cleaner GUI, and has fewer bugs/really annoying quirks than Eclipse.
I've been using Ubuntu and Java for about 6 years now at work. I do a combination of mobile, web, and server development. I've used JEE, Android, Spring, and hobbied in JavaFX (both 1.0 and 2.0). Here is the best I can come up with.
For the most part don't use the Ubuntu packages for anything but OpenJDK. Install Eclipse and/or Netbeans by hand. I like keeping everything in /opt with a symlink to the current version. (IE I will have /opt/tomcat-6 and /opt/tomcat-7 with /opt/tomcat pointing to tomcat 7. Same goes for Groovy, java FX, alternative JDKs, etc).
If you find yourself needing a specific JDK (Oracle 32 bit for Java FX as an example), you should use the alternatives system to point Ubuntu at it. As long as you make sure you get javac, java, and javah updated you will be golden. Eclipse et al behave correctly. Alternatively you can set this up per IDE. It really is a matter of preference.
Ever since OpenJDK got good, most of the problems we had with Java on Linux went away.
TL;DR; Eclipse and Netbeans are good enough. Install OpenJDK from apt and get everything else from the official build. Put everything you need in /opt and use the IDE's platform tools or the Alternatives system to make sure you are using the Java you want.
You appear to be setting JAVA_HOME and PATH only in the current terminal session.
You should adjust your JAVA_HOME and PATH variable in either .bashrc or .bash_profile in your home directory. Then maybe logout and back in. That way the PATH will be adjusted every time you open a new terminal.
https://docs.oracle.com/cd/E19062-01/sun.mgmt.ctr36/819-5418/gaznb/index.html https://linuxize.com/post/bashrc-vs-bash-profile/
With your above command you install java in your home directory. If the software is not explicitly required to be available to only this single user, I'd recommend to stick to the official filesystem hierarchy ( for example see here for a basic explanation The Linux Directory Structure, Explained ).
Since Oracle Java is a prime example for "proprietary software that doesnβt obey the standard file system hierarchy", it would best go to the /opt folder.
- Create a new folder with
sudo mkdir /opt/java - Move the .tar file there and extract it as sudo
- Optionally: Install a symlink to the /usr directory, to run java without the full path
sudo update-alternatives --install /usr/bin/java java PATH_TO_BINARY_HERE 100
Not quite sure what the JAVA_HOME variable is needed for. In Oracle's install manual it is not mentioned. If you do need this to be persistent, you'd have to add it to .bashrc or .bash_profile .