LoginSignup
2
1

More than 5 years have passed since last update.

Javaでこんにちは世界( VimとQuickrunで手早く文法を学ぶっ)

Last updated at Posted at 2018-10-02

Screen Shot 2018-10-03 at 8.11.58.png

Summary

javaファイルをVimQuickrun

改訂履歴

2018/10/03 wed
コメントで shiracamus さんよりアドバイスをいただいたクラス・変数名に関して訂正した
グローバル変数 foo_ に関しては訂正保留中

ファイル構成

$ tree
.
└── MyProj               // project folder ( working folder )
    ├── main
    │   └── Main.java    // entry file
    └── myclass
        └── Hello.java   // your own classes


3 directories, 2 files

Quickrun

\ 'java': {
\   'exec': ['javac -cp %s:p:h:h:h */*.java', 'java -cp %s:p:h:h:h:%s:p:h %s:t:r %a' ],
\   'hook/output_encode/encoding': '&termencoding',
\   'hook/sweep/files': '%S:p:r.class',
\ },

Java's code

entry class

// Main.java
import MyProj.myclass.*;

public class Main {

    public static void main(String[] argv){

        Hello hello = new Hello("world!");
        hello.sayHello();

    }

}

your own classes

// Hello.java
package MyProj.myclass;

public class Hello {

    private String str_ = "hello ";

    public Hello( String s ){
        this.str_ = this.str_ + s;
    }

    public void sayHello(){
        System.out.println( this.str_ );
    }

}

Reference

自作したクラスをimportしたい
quickrun help

2
1
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1