• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem running hello world application  RSS feed

 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks.
I have a problem with running my hello world aplication. Here is the code.

It compiles fine. But I get an exception when I try to run it.

Here is the error message I'm getting:

Exception in thread "main" java.lang.NoSuchMethodException: HelloWorld.main([Ljava.lang.String;)
at java.lang.Class.getMethod(Class.java:1605)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)

Process finished with exit code 1


What is wrong with my code?

PS. I'm using IntelliJ to run this.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Java vendor/implementation is IntelliJ using to run that program and are you sure it picked up the right/latest .class file which has that main method?
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java: version 1.6.0_26
IntellijIDEA Ultimate 11.1.
I cleared .class files before compiling. IntelliJ does that anyway, right?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:
I cleared .class files before compiling. IntelliJ does that anyway, right?


There's a setting to rebuild project before launching the main method. Anyway, what happens if you add that Helloworld class to a specific package:



and then rebuild and relaunch the main method?
 
Tim Cooke
Marshal
Posts: 4050
239
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you cut and paste this from somewhere? If I cut and paste your code directly into my IntelliJ then I get the same error as you. But if I retype it as an exact copy then it works fine. I suspect you've copied in some strangely encoded characters without realising it.
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran Pai wrote:There's a setting to rebuild project before launching the main method. Anyway, what happens if you add that Helloworld class to a specific package and then rebuild and relaunch the main method?

Nothing changed.

Tim Cooke wrote:Did you cut and paste this from somewhere? If I cut and paste your code directly into my IntelliJ then I get the same error as you. But if I retype it as an exact copy then it works fine. I suspect you've copied in some strangely encoded characters without realising it.

What do you mean? I typed this myself.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:Did you cut and paste this from somewhere? If I cut and paste your code directly into my IntelliJ then I get the same error as you. But if I retype it as an exact copy then it works fine. I suspect you've copied in some strangely encoded characters without realising it.


Indeed, that appears to be the case, here's what the OP code really looks like:

public static void m& #1072;in(String[] args) {


(I intentionally added a space between the & and # characters in there)
 
Tim Cooke
Marshal
Posts: 4050
239
Clojure IntelliJ IDE Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I hex dumped it. First one is your "main", second is mine.

0000: 6D 00 30 04 69 00 6E 00 m.0.i.n.
0010: 6D 00 61 00 69 00 6E 00 m.a.i.n.

They are not the same.
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have a method m0in.
So I should change my method name? I'll try!
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked. I deleted my method name and then retyped it.
You are the best!!!
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:I don't have a method m0in.
So I should change my method name? I'll try!


No, that's not what Tim meant. The problem seems to be with the character encodings used by the IDE. Can you take a look at this article on how to setup IntelliJ IDE to use the correct encoding http://blog.jetbrains.com/idea/2013/03/use-the-utf-8-luke-file-encodings-in-intellij-idea/?
 
Tim Cooke
Marshal
Posts: 4050
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
а appears to be the Russian HTML Code for the character 'a' (source: http://character-code.com/russian-html-codes.php)
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you saying that I should not put cyrylic letters in method names? Ouch!
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Are you saying that I should not put cyrylic letters in method names? Ouch!


The JLS states http://docs.oracle.com/javase/specs/jls/se5.0/html/lexical.html#3.1
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Are you saying that I should not put cyrylic letters in method names? Ouch!

Why? The Java documentation is clear that the method is named "main" - all ASCII. you should not expect it to work if you use other characters.

Aside from that, Java source code is assumed to be ASCII. If it's not, you need to use the "-encoding" switch during compilation.
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In cyrillic, method m0in runs you!
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Are you saying that I should not put cyrylic letters in method names? Ouch!

What would a good Polish lad be doing using Cyrillic? As far as I'm concerned it's only good for cryptic comic stuff like:
БЭБZ ИΗ БΛΥ ЖИНΖ
(I think I got it right - finally).

Winston
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:What would a good Polish lad be doing using Cyrillic?

Hmmmm. Cyrylic was necessary for this April Fools' question to "work" ;).

Winston Gutkowski wrote:БЭБC ИΗ БΛΥ ЖИНΖ
(I think I got it right).


I don't get it ;)
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:I don't get it ;)

Read it out loud (with the 'Z' change ).

Winston
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:I don't get it ;)

Mind you, it's been about 40 years since my last Russian lesson...

Winston
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, still not getting it. It's too cryptic ;)
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Sorry, still not getting it. It's too cryptic ;)

OK, spell it out in English (ie, translate each character into its English equivalent or sound) and then read it out.

Sheesh. That was our favourite pastime during my year of Russian. Maybe it's lost it's impact now...

Winston
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Pawel Pawlowicz wrote:Sorry, still not getting it. It's too cryptic ;)

OK, spell it out in English (ie, translate each character into its English equivalent or sound) and then read it out.

Sheesh. That was our favourite pastime during my year of Russian. Maybe it's lost it's impact now...

Winston

Yes, I get it now. But you have used Υ instead of У, Η (greek eta) instead of Н (cyrylic N), Λ instead of Л and Z instead of З ;)
40 years is a long time :P

Then, typing БЭБЗ ИН БЛУ ЖИНЗ in google translate and letting it "say" it would help a little ;)
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Yes, I get it now. But you have used Υ instead of У, Η (greek eta) instead of Н (cyrylic N), Λ instead of Л and Z instead of З ;)
40 years is a long time :P

Yup. I was pretty sure 'Z' was wrong, but it was the only thing I could find on OpenOffice (forgot it was a '3'; probably should have stuck with 'C').

But Λ instead of Л? That's splitting hairs isn't it? It's the same sound (and practically the same symbol) in both languages. Maybe not to a Russian, though.

However, after all this panning of Russians and their silly alphabet, I should redress the balance a bit by linking to their anthem, which is IMO, the best one ever (although I slightly preferred the Soviet version, simply because I knew some of the words - who cares if they were talking about crushing the bourgeoisie and all associated with them).

Happy April Fools Pawel.

Winston
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:
Winston Gutkowski wrote:What would a good Polish lad be doing using Cyrillic?

Hmmmm. Cyrylic was necessary for this April Fools' question to "work" ;).

Good one
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:But Λ instead of Л?


Λ was the way I learned to do it in handwriting, and Л is the way I always saw it in printed text. Some handwritten characters are quite different from their printed versions, have a look here http://en.wikipedia.org/wiki/Cyrillic_script#Letterforms_and_typography for example.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Λ was the way I learned to do it in handwriting, and Л is the way I always saw it in printed text. Some handwritten characters are quite different from their printed versions, have a look here http://en.wikipedia.org/wiki/Cyrillic_script#Letterforms_and_typography for example.

Yeah, I do remember that (especially the 'm' with the line over it for 'T'). I was just using Cyrllic characters from OpenOffice which are probably Greek and Russian mixed.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!