Can you compile and execute Java files in Geany with one command?

Is there a way to compile and execute java files with a single command in, say F1, Geany?

It's much more convenient than clicking f5 to wait for the class to compile first, and then F1execute that compiled file.

+3


source to share


2 answers


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.

0


source


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.

+4


source







All Articles