LoginSignup
7
8

More than 5 years have passed since last update.

.javaから.jar、そして実行まで

Last updated at Posted at 2015-04-19

java初心者の僕がjavaファイルからjarファイル作って実行するまで

↓元ファイル

hello.java
public class hello {
    public static void main(String[] args) {
        System.out.println("Hello " + args[0]);
    }
}

javacでクラス作って〜

$ javac hello.java
$ ls
hello.class hello.java

makefile書いて〜

hello.mf
Main-Class: hello

jar作って〜

$ jar cfmv hello.jar hello.mf *.class
マニフェストが追加されました
hello.classを追加中です(入=574)(出=354)(38%収縮されました)

実行!

$ java -jar hello.jar World!
Hello World!

一丁あがり!

ハマったのはmakefile作るとこですかね。

$ jar cvf hello.jar *.class
マニフェストが追加されました
hello.classを追加中です(入=574)(出=354)(38%収縮されました)
$ java -jar hello.jar
hello.jarにメイン・マニフェスト属性がありません

えっ!
みたいな

// Larry Carlton & Tak Matsumoto「TAKE YOUR PICK」を聞きながら作業しました。

7
8
0

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
7
8