• Post Reply Bookmark Topic Watch Topic
  • New Topic

Zoo.java File Creation in IntelliJ  RSS feed

 
Ross Michael
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dumb noob question here,

My first attempt at Java using the OCA Study Guide, i am pretty lost, chosen IntelliJ IDEA as it is what i am familiar with coming from PHP, installed JDK 1.8.0_102

I still don't understand the file structure of the Java project environment and not even sure how to create files!

I reached the part in the book where:

"To compile and execute this code, type it into a fi le called Zoo.java and execute the following:
$ javac Zoo.java
$ java Zoo"


I add a file called Zoo.java in src and paste that code in it and here is my compiler results:

Information:Using javac 1.8.0_102 to compile java sources
Information:java: Errors occurred while compiling module 'Zoo'
Information:Module "Zoo" was fully rebuilt due to project configuration/dependencies changes
Information:10/12/2016 9:36 PM - Compilation completed with 1 error and 0 warnings in 2s 353ms
C:\Users\UserName\IdeaProjects\Zoo\src\Zoo.java
Error:‍(1, 1) java: class, interface, or enum expected


What is going on? please advise .. thanks
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your code wrapped in code tags (Use Code button above input box).

Error:  (1, 1) java: class, interface, or enum expected

It looks like there is a syntax error on line 1.
 
Ross Michael
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i figured that i should use code tags right after i submitted the post but i could not find any way to edit the post.

i know there is an error in line 1 but i just don't know why or how to fix it, did i follow the tutorial in the book correctly?

Just don't know if i am going in the right direction or not, anyways i will just continue reading the book, maybe i will figure it out later.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want help with the error, you need to post the code.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I fiddled your post slightly to remove an unwanted
Let me try some guessing about your compiler error.
Have a look at the old Sun style guide; that link shows the structure of a Java® source file. Don't spend more than 5 minutes on that page. You may have comments before your class starts, a package name, and import declarations. Then you have the header for the class, which at the beginner's stage will look like this:-
public class Zoo
You may miss out the word public. Now, the tiniest spelling errors before the name of the class, or anything else written which isn't comment, package name or import, or any spelling errors in them, will produce a compiler error
class interface or enum expected
at the beginning of the file. If you get such an error from the end of the file, it means something different. You obviously have some sort of spelling error before the name of the class. Examples of such errors are:-
Public class Zoo
publicclass Zoo
public Class Zoo
public class. Zoo
Any of those will produce such an error message.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!