I started to test the questions of the csdn black horse programmer, but I found that the motherboard With the capacitor pins rusted started to run eclipse.
Change to Emacs .. I don't want to remember tedious commands any more.
Use gedit.
First open gedit, go to tools-> external tools, and create a new command. This command is used for compilation, and the name is obtained by yourself. The shortcut key is set by yourself, for example, <F1>, then, in the Command box on the right, enter:
# Compiles the current open Java source file.
Echo "Compiling:" $ gedit_current_document_path
Echo '--------------------'
Javac $ gedit_current_document_path
Next, follow the above method to create another command to run the compiled class file. The command box contains the following content:
# Runs a compiled Java source file.
Echo "running:" $ gedit_current_document_path
Echo '--------------------'
Bash ~ /. Gedit/java_run $ gedit_current_document_dir $ gedit_current_document_name
Finally, create a new. gedit folder in your home directory, create a new java_run file, and copy the following content to it:
#! /Bin/bash
# To be used with gedit tools to run a compiled Java source file.
CD $1
Java $ {2: 0 :$ {# 2}-5}
(Note: The article found on the internet is similar to this article. This shell file is a bit faulty. It uses regular expressions and some problems cannot be matched. I changed it to the original string operation here, available !)
Now write a test Java, save it, and compile and run it according to the shortcut keys you set. For example, in my settings, first compile according to <F1>, then <F2> Run, OK, success
Test. Java:
Public class test {
Public static void main (string [] ARGs ){
System. Out. println ("Oh! Shit! ");
}
}
<F1>:
Running tool: javac
Compiling: Test. Java
--------------------
Complete.
<F2>:
Running tool: Java
Running:/home/Hang/desktop/test. Java
--------------------
Oh! Shit!
Complete.