超不定期雑記

~プログラムとかサイエンスとかいろいろと~

目次

Blog 利用状況

ニュース

書庫

Java での開発の勉強をしてみる(3) Eclipse で Hello world!

Eclipse のインストールが終わったので、次はおなじみの "Hello world!" を作ってみる。
Eclipse にはチュートリアルがあり、その先頭には当然 "Hello world!" が収録されている。まずはこれを追っかけてみることにした。

「ようこそ」画面の「チュートリアル」をクリックすると、チュートリアルが6件収録されているのがわかる……日本語化はされないのね。
ここで "Create a Hello World application" を選択すると、VisualStudio とよく似たウィンドウ構成になる。この状態を「ワークベンチ」というらしい。
さらにチュートリアル状態では、右端に「ようこそ」ウィンドウが出ていて、ここで作業指示してくれるのでわかりやすい。英語だけど。
ヘルプみたいな別ウィンドウってのは、意外と読みにくいんだよね。

  1. Java パースペクティブを開く
    デフォルトで "Java パースペクティブ" になっているんだが。もしなっていなければ、メインメニューの [ウィンドウ]-[パースペクティブを開く]-[Java] を選択する。[Java 参照] でないことに注意。
  2. Java プロジェクトを作成する
    メインツールバー(デフォルトでは一番左のツールバー)にある [新規] アイコンから "Java プロジェクト" を選択する。"新規 Java プロジェクト" ダイアログが表示されるので、 "プロジェクト名" に "HelloWorld" と入力して "終了" ボタンを押す。その他のオプションはすべてデフォルト。
  3. HelloWorld クラスを作る
    再びメインツールバーの [新規] アイコンから "クラス" を選択する。"ソース・フォルダー" に "HelloWorld/src" と入力されていることを確認する。"名前" に "HelloWorld" と入力し、"public static void main(String[] args)" チェックボックスを選択して "終了" ボタンを押す。
  4. 出力ステートメントを作成する
    main() メソッドに下記を記述する。 System.out.println("Hello world!");
  5. Java アプリケーションを実行
    "パッケージ" エクスプローラーで右クリックをし、[実行]-[Java アプリケーション] を選択する。すると "コンソール" ウィンドウが立ち上がり、Hello world! と表示される。

以下、雑感とかメモとか。

  • 書き方そのものは C# とあんまり変わらない。C# の成立を考えれば当然なんだが。
  • Java のエントリポイントになるメソッドは C と同じくmain()。ただし、プロトタイプは "public static void main(String[] args)" でなければならない。
    • 上記のプロトタイプに従った main 関数がないと、実行時に「選択にはメイン型が含まれていません」エラーが出る。
    • int を返すこともできないようだけど、終了コードを返すにはどうするんだろう?
      • コンソールアプリ作ることを考えると、終了コードって必要だよね?
    • main() の引数を削除することもできない。
      • 必要なければ無視するだけなんだけど。
    • エントリポイントは static でなければならない。なるほど、理にかなっている。
      • そういえば、C# もエントリポイントは static だった……。
  • Eclipse のキーバインドとか色分け設定等々を VisualStudio に合わせたい。
    • Java 屋さんからは否定されるかもしれんが、私が慣れている開発環境は VisualStudio だ!
  • オートフォーマットの設定はどうするんだろう。たとえば開き中括弧の前で改行しないってのは、すっげー違和感がある。

投稿日時 : 2009年2月25日 16:58

Feedback

# re: Java での開発の勉強をしてみる(3) Eclipse で Hello world! 2009/02/26 9:37 読者

> int を返すこともできないようだけど、終了コードを返すにはどうするんだろう?
System.exit(xx) があります。

>オートフォーマットの設定はどうするんだろう。
[設定]から出来ますよ。

# re: Java での開発の勉強をしてみる(3) Eclipse で Hello world! 2009/02/26 11:54 guicheng

読者さん、コメントありがとうございます。

> System.exit(xx) があります。

なるほど、終了メソッドを使ってエラーコードを返すわけですか。
それなら main は void の方がわかりやすいですね。


> [設定]から出来ますよ。

[ウィンドウ]-[設定] で設定ダイアログを開いて、[Java]-[コード・スタイル]-[フォーマッター] ですね。
ある程度予想はしてましたが、調整項目がかなり多いですね。
でも設定しやすそうなので、少し追い込んでみます。

#  ??????????????????????????????????????????????????? : mitto???????????? 2011/06/07 15:56 Pingback/TrackBack

??????????????????????????????????????????????????? : mitto????????????

#  WebBrowser?????????????????????????????????????????????????????? : mitto???????????? 2012/01/18 0:31 Pingback/TrackBack

WebBrowser?????????????????????????????????????????????????????? : mitto????????????

# http://burberry.suppa.jp/ 2012/11/07 0:45 バーバリー バッグ 新作

匿名なのに、私には誰だか分かる・・・(^_^;)ありがとう。。。

# Hi! I just wanted to ask if you ever have any problems with hackers? My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no data backup. Do you have any methods to stop hackers? 2019/04/05 14:47 Hi! I just wanted to ask if you ever have any prob

Hi! I just wanted to ask if you ever have any problems
with hackers? My last blog (wordpress) was hacked and I ended up losing a
few months of hard work due to no data backup.
Do you have any methods to stop hackers?

# If some one needs to be updated with most up-to-date technologies after that he must be go to see this website and be up to date daily. 2019/05/07 15:17 If some one needs to be updated with most up-to-da

If some one needs to be updated with most up-to-date technologies after that he must be go to
see this website and be up to date daily.

# Your style is very unique compared to other folks I have read stuff from. I appreciate you for posting when you have the opportunity, Guess I will just bookmark this web site. 2019/05/12 12:26 Your style is very unique compared to other folks

Your style is very unique compared to other folks I
have read stuff from. I appreciate you for posting when you have
the opportunity, Guess I will just bookmark this web site.

# magnificent issues altogether, you just gained a emblem new reader. What would you suggest about your publish that you simply made some days in the past? Any certain? 2019/05/13 16:28 magnificent issues altogether, you just gained a e

magnificent issues altogether, you just gained a emblem new reader.
What would you suggest about your publish that you simply made some
days in the past? Any certain?

# Hello! I could have sworn I've been to this site before but after browsing through some of the articles I realized it's new to me. Nonetheless, I'm definitely pleased I came across it and I'll be bookmarking it and checking back frequently! 2019/05/14 14:59 Hello! I could have sworn I've been to this site

Hello! I could have sworn I've been to this site
before but after browsing through some of the articles I realized it's new to
me. Nonetheless, I'm definitely pleased I came across it and I'll be bookmarking it and checking back frequently!

# Yes! Finally someone writes about descargar facebook. 2019/08/19 21:05 Yes! Finally someone writes about descargar facebo

Yes! Finally someone writes about descargar facebook.

# Very descriptive article, I loved that bit. Will there be a part 2? 2019/09/07 8:06 Very descriptive article, I loved that bit. Will t

Very descriptive article, I loved that bit. Will
there be a part 2?

# My brother suggested I would possibly like this web site. He was entirely right. This put up actually made my day. You can not believe just how much time I had spent for this information! Thanks! 2019/10/09 9:01 My brother suggested I would possibly like this we

My brother suggested I would possibly like this web
site. He was entirely right. This put up actually
made my day. You can not believe just how much time I had spent for this information!
Thanks!

# Spot on with this write-up, I seriously think this site needs far more attention. I'll probably be returning to see more, thanks for the advice! 2019/10/29 21:06 Spot on with this write-up, I seriously think this

Spot on with this write-up, I seriously think this
site needs far more attention. I'll probably be returning to see more, thanks for the advice!

# I think this is one of the most vital information for me. And i'm happy reading your article. But wanna commentary on few basic issues, The site taste is perfect, the articles is really great : D. Excellent task, cheers 2019/11/04 20:41 I think this is one of the most vital information

I think this is one of the most vital information for me.

And i'm happy reading your article. But wanna commentary on few basic
issues, The site taste is perfect, the articles is really great : D.
Excellent task, cheers

# Have you ever thought about including a little bit more than just your articles? I mean, what you say is fundamental and all. However just imagine if you added some great images or video clips to give your posts more, "pop"! Your content is e 2019/11/11 7:24 Have you ever thought about including a little bit

Have you ever thought about including a little bit more than just your articles?
I mean, what you say is fundamental and all. However just imagine if you added
some great images or video clips to give your posts more, "pop"!
Your content is excellent but with pics and video clips, this blog could undeniably be one
of the most beneficial in its niche. Awesome blog!

# Very good blog post. I absolutely appreciate this site. Stick with it! 2019/11/14 23:13 Very good blog post. I absolutely appreciate this

Very good blog post. I absolutely appreciate this site. Stick with it!

# Hey! I know this is kind of off-topic but I had to ask. Does managing a well-established blog like yours take a large amount of work? I am brand new to writing a blog however I do write in my journal daily. I'd like to start a blog so I can easily sha 2019/11/22 0:39 Hey! I know this is kind of off-topic but I had to

Hey! I know this is kind of off-topic but I had to
ask. Does managing a well-established blog like yours take a
large amount of work? I am brand new to writing a blog however
I do write in my journal daily. I'd like to start a blog so I can easily share my
personal experience and thoughts online. Please let me know if you have any kind of suggestions or tips for new aspiring blog owners.
Thankyou!

# Hey! I know this is kind of off-topic but I had to ask. Does managing a well-established blog like yours take a large amount of work? I am brand new to writing a blog however I do write in my journal daily. I'd like to start a blog so I can easily sha 2019/11/22 0:40 Hey! I know this is kind of off-topic but I had to

Hey! I know this is kind of off-topic but I had to
ask. Does managing a well-established blog like yours take a
large amount of work? I am brand new to writing a blog however
I do write in my journal daily. I'd like to start a blog so I can easily share my
personal experience and thoughts online. Please let me know if you have any kind of suggestions or tips for new aspiring blog owners.
Thankyou!

# Hey! I know this is kind of off-topic but I had to ask. Does managing a well-established blog like yours take a large amount of work? I am brand new to writing a blog however I do write in my journal daily. I'd like to start a blog so I can easily sha 2019/11/22 0:41 Hey! I know this is kind of off-topic but I had to

Hey! I know this is kind of off-topic but I had to
ask. Does managing a well-established blog like yours take a
large amount of work? I am brand new to writing a blog however
I do write in my journal daily. I'd like to start a blog so I can easily share my
personal experience and thoughts online. Please let me know if you have any kind of suggestions or tips for new aspiring blog owners.
Thankyou!

# Hey! I know this is kind of off-topic but I had to ask. Does managing a well-established blog like yours take a large amount of work? I am brand new to writing a blog however I do write in my journal daily. I'd like to start a blog so I can easily sha 2019/11/22 0:42 Hey! I know this is kind of off-topic but I had to

Hey! I know this is kind of off-topic but I had to
ask. Does managing a well-established blog like yours take a
large amount of work? I am brand new to writing a blog however
I do write in my journal daily. I'd like to start a blog so I can easily share my
personal experience and thoughts online. Please let me know if you have any kind of suggestions or tips for new aspiring blog owners.
Thankyou!

# I am not sure where you are getting your info, but good topic. I needs to spend some time learning more or understanding more. Thanks for great information I was looking for this information for my mission. 2019/11/26 23:09 I am not sure where you are getting your info, but

I am not sure where you are getting your info,
but good topic. I needs to spend some time learning more or understanding more.

Thanks for great information I was looking for this information for my mission.

# 2 Find this Pin It was a 5 2019/12/25 7:31 Typicalcat21

Hi, I do think this is an excellent site. I stumbledupon it ;) I am going to come back once again since i have bookmarked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

# 7 Tie the back But getting to 9 2019/12/25 19:16 Typicalcat49

http://www.jewish.co.il/%ef%bb%bfno-fee-cheapest-senior-singles-online-dating-services.html 60's plus seniors dating online websites in texas http://dmarcas.co/no-membership-needed-senior-online-dating-website-blogs.wankuma.com.pdf where to meet ukrainian senior citizens in canada

# 6 More pollution, lesser Regardless of the 9 2019/12/25 21:13 Typicalcat03

http://www.eurosupportgroup.com/%ef%bb%bfmature-online-dating-sites-dating-online-sites/ where to meet singles in utah no payments http://kapwein24.de/50's-and-above-seniors-online-dating-site-blogs.wankuma.com.pdf where to meet nigerian singles in ny free

# 0 A brief but The year-old student 2 2019/12/26 8:54 Typicalcat80

http://www.bursaelektrikciler.com/2019/10/14/%ef%bb%bfsenior-best-rated-serious-relationship-dating-online-website/ what dating online websites are with no fees http://alwaadvokat.se/absolutely-free-mature-dating-online-site-blogs.wankuma.com.pdf las vegas black senior dating online website

# 7 Severely polluted industrial Who has worked 2 2019/12/26 10:20 Typicalcat81

https://glasslabyrinth.com/2019/11/21/%ef%bb%bfno-sign-up-seniors-dating-online-site/ free highest rated seniors dating online service http://hercamltd.com/online-dating-websites-for-50-plus-blogs.wankuma.com.pdf las vegas japanese senior dating online website

# 8 The keepers assigned It was a 2 2020/01/02 4:10 Typicalcat94

http://wonderfulcoworking.com/%ef%bb%bfno-register-required-newest-seniors-online-dating-sites/ where to meet korean singles in florida https://luqmen.com/most-reliable-senior-online-dating-service-free-blogs.wankuma.com.pdf brazilian senior dating online services https://www.cela-al.com/%ef%bb%bfmost-visited-mature-online-dating-website-without-payment/ where to meet italian seniors in denver http://shubhrasecurityservices.com/50's-plus-senior-dating-online-website-free-blogs.wankuma.com.pdf senior dating online sites with no fees

# What's up to every single one, it's genuinely a fastidious for me to go to see this website, it contains helpful Information. 2020/01/03 3:02 What's up to every single one, it's genuinely a fa

What's up to every single one, it's genuinely a fastidious for me to go to see this website,
it contains helpful Information.

# I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing these statistics. 2020/01/07 11:29 I am genuinely pleased to read this webpage posts

I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing
these statistics.

# I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing these statistics. 2020/01/07 11:30 I am genuinely pleased to read this webpage posts

I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing
these statistics.

# I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing these statistics. 2020/01/07 11:31 I am genuinely pleased to read this webpage posts

I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing
these statistics.

# I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing these statistics. 2020/01/07 11:32 I am genuinely pleased to read this webpage posts

I am genuinely pleased to read this webpage posts which contains tons of valuable facts, thanks for providing
these statistics.

# Hi, i think that i saw you visited my website thus i came to “return the favor”.I'm attempting to find things to improve my web site!I suppose its ok to use some of your ideas!! 2020/06/16 15:42 Hi, i think that i saw you visited my website thus

Hi, i think that i saw you visited my website thus i came to “return the favor”.I'm attempting to find things to improve my web
site!I suppose its ok to use some of your ideas!!

タイトル  
名前  
Url
コメント