Java has much differences with PHP. I suggest, if you
want to learn a new programming language, read the
example program's source code and write it. Just write
the code you read. Then, please take attention, how
the new language differ from the old.
Second, you can use the java IDE or Text Editor that
support syntax highlighting (such as editplus). This
will help you to determine the syntax error before you
compile your code.
The last, read the books or java tutorial as Anthony
Eden suggested.