# Challenge

You want to give some simple demos in java, kotlin or python (or any other language for that matter) and have the output shown immediately as a tooltip.

# Solution

## Java

• go to Bundles > Edit Bundles... > Java > Menu Actions > Compile & Run
• Change according the picutre

• The original code looks like this:
• You need to change it to the commands below:
• The script above will look for a compile.sh script in the folder of your java file and if found it wil run that. You can do whatever you like in that compile.sh file. If no such file is found it will compile the current java file being edited and run that one.
• Now just command+R on a Java class…
• The output will be shown as a tooltip at your cursor.

## Kotlin

• The Kotlin plugin is to be gotten here it is strongly based on this bundle but has added a run and run with args command to the bundle. I did a pull request to the original repo but have not gotten any response yet.

Again this bundle is setup in such a way that it will look for a kotlin.sh file in the folder where the file you want to compile is located. If found it will run that file. Do whatever you want there. If not found the script will determine if the kotlin is a script file (*.kts) and if so it will run it accordingly. If it is a standard kotlin file (*.kt) it will compile it and then run it. It of course needs a top level declaration in that case.

The whole idea of this way of compiling is to give small demos, so it is not really set up to do much more than accomodate that.

If you want to do it yourself here is the code for the Run command (cmd+r)

Code for the run with parameters (option+cmd+r):

Note that the bundle needs a Java 1.8 JDK to work. When running on Java 9 it wil give warnings about illegal accessing stuff. So this bundle explicitely sets the java home to a java 1.8 location. When that problem has been solved it might not be nessesary to do that anymore.
Note als that the commands are performed in an echo. This is because (compile) errors will in this case also be shown as a tooltip. Otherwise this would result in an textmate popup window.

## Python

Just change the settings in the python bundle to give the results in the tooltip window (see java section)

# Change tooltip font size

In a terminal perform the following command:

Where 24 will be the size of your tooltip font

# Comments / tips and tricks

Comments on this article and other tips and tricks are much appreciated…