Java compilation settings for gedit in Ubuntu

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.