• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

meaningless compilation error

 
jay thakkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


y the compilation error occurd???

i m new in java but i follow oracle documentation n i m reading a book on java called "thinking in java"

i m using netbeans 6.9 which i downloaded to learn javaFx language but i can make java applications also... so i guess that must not be n issue n the JDK is 1.7

please please i can't sleep because of this error.. please help
 
Winston Gutkowski
Bartender
Pie
Posts: 10277
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jay thakkar wrote:please please i can't sleep because of this error.. please help

Jay,

1. Welcome to JavaRanch.
2. Please EaseUp (←click).
3. TellTheDetails (←click). What exactly is the error you''re getting?

I can assure you that the error is NOT 'meaningless'. Moreover, it's highly likely that it tells you exactly what the problem is. I suggest you re-read the message carefully, and see if you can work it out for yourself. If you still have problems, come back with the message you got, exactly as it was displayed to you.

Winston
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please read the UseCodeTags page. It makes reading code a lot easier. I added the tags to your post.

The problem you are seeing is that you can't run arbitrary code in side an Class body - you can only do variable declaration and in-line initializations. so this would work because the variable declaration and initialization is on the same line:

If you want the initialization to be separate from the declaration, you can do that but you need to put the initialization into a block - usually a constructor:

But you could also use 'instance initializers' (but these aren't very common, so it can confuse people.):
 
jay thakkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry guys for replying so late.... i m glad that people are so much "helping natured" here so will soon master java technologies

dont know the problem but installed JDK 7.0 and now i m able to run all the programs...

i guess the problem was to me that i just downloaded javaFX 2.1 jdk... so it did not supported basic JAVA syntax.... please correct me if i m wrong.. i will like to learn something new which i dont know
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again Jay.

Jay wrote: please please i can't sleep because of this error.. please help


That sounds more like a 911 call than a java exception / error. Like Winston said, ease up, go step by step and post your doubts here. No need to say please. We will help you. Only condition is you have to show some effort first. If you get stuck, we'll help you out.


dont know the problem but installed JDK 7.0 and now i m able to run all the programs...

i guess the problem was i just downloaded javaFX 2.1 jdk... so it did not supported basic JAVA syntax.... please correct me if i m wrong.. i will like to learn something new which i dont know


It is good that you are not facing any problem after new installation. But make a habit of studying the problem first, why it happened, study the console logs, stack trace, error message etc. Try to find out patterns. It is very important to understand the why part. Don't just jump up if it works. Try to understand why it worked too. Just guessing will not help you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic