aspose file tools*
The moose likes Beginning Java and the fly likes laying out Java environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "laying out Java environment" Watch "laying out Java environment" New topic
Author

laying out Java environment

Alex Ss Smith
Greenhorn

Joined: Dec 06, 2012
Posts: 3

So the classic System.out.println("Hello Ranch"); ran without a problem but on code lines beyond that, for example age = nextInt(); , receive a "selection does not contain a main type" error. so i guess my question is what is the correct concise language to describe this issue and followed by what solution?

"I'm very responsible. Whenever something goes wrong they always say I'm responsible."
Aj Prieto
Ranch Hand

Joined: Sep 28, 2012
Posts: 75

The nextInt() method usually implies a Scanner class.

Read this Scanner, it'll tell you how to use it.


Da mihi sis bubulae frustum assae, solana tuberosa in modo Gallico fricta ac quassum lactatum coagulatum crassum.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14430
    
  23

Welcome to the Ranch, Alex.

Please show use your code, explain exactly what commands you are trying to run and what the error messages are that you get. The more precise you ask your question, the better people can help you and the quicker you'll solve the problem.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Alex Ss Smith
Greenhorn

Joined: Dec 06, 2012
Posts: 3

thanks for help y'all. I'm re downloading eclipse as we speak and well see how that goes.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
Alex Smith Smith wrote: . . . I'm re downloading eclipse as we speak and well see how that goes.
Beware: if you really are a beginner, using an IDE like Eclipse usually makes learning even more difficult than it already is.

If you are using Scanners, beware of a pitfall described here. You can also write yourself a utility class using Scanners which validates entry: start reading here.
Alex Ss Smith
Greenhorn

Joined: Dec 06, 2012
Posts: 3

so far..
import java.util.Scanner;
public class JavaTutorial2Math {
static void main(String[] args){
Scanner in = new Scanner(System.in);
int age;
System.out.println("How old are you?");
age = in.nextInt();
if (age >= 21)
System.out.println("You may enjoy a drink.");
else
System.out.println("You are not old enough to drink.");
}
}
and the program feeds me "selection does not contain a main type" unlike "Hello Ranch" so something with this scanner class causes this.
many thanks
Aj Prieto
Ranch Hand

Joined: Sep 28, 2012
Posts: 75

Well, you're missing "public" on the second line, otherwise it won't run.

After adding that, the program runs fine for me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: laying out Java environment