Can you compile and execute Java files in Geany with one command?
You can try creating a wrapper script that compiles the class first and then runs it. Then customize that shell script instead of pointing Geany to javac
and java
accordingly.
In the opposite direction, you have to handle compilation failures in the script, which sounds ugly.
I would recommend sticking to the existing workflow at Geany.
If you are looking for advanced functionality, you might consider upgrading to a real IDE like Eclipse or Netbeans.
source to share
Yes, you can!
While editing the Java file, go to Build> Install Build Commands. In Java commands, click the first blank label and give it a name, eg. Compile & Execute
... Then, in the Command field, enter the command line that you will use in the terminal to compile and execute your files, replacing the file and class names with variables (see the Geany manual ).
For example, on Linux you can use javac "%f" && java "%e"
. (Using && ensures that the resulting class file will only be executed when compilation is successful.)
Click OK and reopen the Build menu to see that the Compile and Run command now exists. In my case, Geany automatically assigned a shortcut key to it F9. If there is no keyboard shortcut, you can assign one in Settings> Keys.
Pressing the keyboard shortcut will now enter the entered command line and display its output in the Compiler tab of the message window. Alternatively, you can create a build command in Execute commands instead of Java commands and it will run in a terminal window.
source to share