- Showing all posts in category: Java
# Using SDKMan with Oracle JDK
Published on 20-10-2019

SDKMAN! does not distribute any Oracle JDK anymore. I think they stopped providing it for a while now(see their Medium article). I am used with the way of having multiple JDK versions managed by SDKMAN! and just switch between version using one command.

For my current project I have to use a certain Oracle JDK version, which is been installed locally on my machine, but I want to have it managed by SDKMAN!. Fortunately you can add your local JDK version by using the local install feature:

sdk install java 10-zulu /Library/Java/JavaVirtualMachines/zulu-10.jdk/Contents/Home


More info: SDKMAN! Local installation

If you were familiair with Eclipse you know that when you would save java class it will build automatically. With IntelliJ you don't have to spam the CTRL + S combination anymore because it will save automatically but there is only one problem. Your class will not be compiled.
Some developers prefer to compile manually because of the performance of the IDE but it can trick you into weird behavior if you forget it once. Especially when developing microservices where you are running 5 instances of IntelliJ.

IntelliJ has the option to build project automatically, BUT it only works while not running / debugging. How sad that is.

The problem I was facing

I was developing a Spring Boot application using Spring Boot Developer Tools which comes with a neat feature where classes are being reloaded. The dev tools only restarts the ServletContext within seconds. The main problem was that it only happens when the class is being compiled. So in Intellij you had to trigger a build yourself while in Eclipse when you would save your class, it will compile automatically even when running.

In IntelliJ it is possible to override this behavior to build automatically even when the application is running.

The setting we want to override is this:


1. Open the registry

2. Look for and enable it

Keep the description in your mind in case you get into weird behaviour.

Close and now you are done. 





I was trying to get a readable output of a stored procedure in Oracle SqlDeveloper but the lines were truncated after 90 characters. The tool didn't had the option to change the linesize for the script output.

It was faster for me to write this in Java to get the readable output of the query.

This code will print the column names with the record values.

      ResultSet rs = getResultSet()
      while ( {
        int columnCount = rs.getMetaData().getColumnCount();
        List<String> results = new ArrayList<>();
		//Columnindex is one based.
        for (int i = 1; i <= columnCount; i++) {
          String columnName = rs.getMetaData().getColumnName(i);
          String value = rs.getString(i);
          results.add(columnName + "=" + value);