Results 1 to 7 of 7
  1. #1
    Zeezj's Avatar
    Zeezj is offline Member
    Join Date
    Mar 2011
    Location
    Cambridge, MA
    Posts
    11
    Rep Power
    0

    Default help with running things (very new to java, so don't laugh...)

    help? i need to know how to run this...
    i have just started yesterday with java and i figured i could ask you guys for help. i don't know how to run this thing.
    Java Code:
    void main( ) {
    
    	int Awesome;
    
    	printLine("on a scale of 1 to 10, how awesome are you?");
    	Awesome = readInt();
    	
    	if ((Awesome < 6) && (Awesome > 1)) {
    		printLine("stop being so emo and get some self esteem. try for like, 6 or above, cause anything below five is just plain emo.");
    	}
    	
    	if ((Awesome > 6) && (Awesome < 11)) {
    		printLine("that's pretty damn awesome. seriously, you should, like, go for the world record of awesomeness...");
    	}
    
    	if (Awesome > 11) {
    		printLine("yeah, nice try buddy. nobody is that awesome. i said on a scale of one to TEN!");
    	}
    
    	if (Awesome < 1) {
    		printLine("dude, you need a therapist...");
    	}
    
    }
    what do i need to do? is there a way to run this at all or have i left something out? most of what i have learned is from this program called JUDO - Java IDE for Children and Beginning Programmers, which is designed to teach java to either children or people new to coding, and i can say i fit both of those criteria...

    p.s. i have access to eclipse if i need it

    p.p.s. i mean run it on something else other than JUDO (so i can see if i can email it to my friends), so don't say "just run it on the thing you were using"
    Last edited by Zeezj; 03-23-2011 at 03:09 PM. Reason: yet another p.s.
    from the desk of August Underhill-Proulx, CEO of Awesomecorp ltd.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    me gusta

    I like the pic.

    Ok now lets go into some basics. First it's:
    Java Code:
    public static void main(String[] args)
    it needs to be like that. Ill be brief for now, but it needs to be public and static so the jvm can access it when you run the program, and the args don't need to be used, but are supplied.

    The next thing I notice right away is that this method is by itself. In java, everything is an object.

    For example in a small program(hello world) it should look something like this
    Java Code:
    public class HelloWorld{  //this is the class
      public static void main(String[] args){
        System.out.println("hello, world");
      }
    }
    First you create a class, which is where I commented, then you add methods. A class can have many methods, in this example it only has 1, main.

    Any classes can contain a main method, but they don't NEED to have one.

    Try putting your code in a class
    Java Code:
    public class MyClass{
      your code here
    }
    This file has to be saved as MyClass.java(capitalization is important)

    Then try to compile and run it and see what happens. You may run into more errors, if you do we can work on them next.

  3. #3
    Zeezj's Avatar
    Zeezj is offline Member
    Join Date
    Mar 2011
    Location
    Cambridge, MA
    Posts
    11
    Rep Power
    0

    Default

    apparently, it was teaching me a simplified version of java that is probably waaaaay out of date...:mad:

    ok, i did what you said, but i still don't know what to run it on though. i'm using the latest version of ubuntu, so it gives me an option to run it if i click "open,"and i did, but it still didn't run; i'm not sure that would even work if my code was perfect in every way. i might have missed some things so if i did, tell me so i don't mess up again lol.
    Java Code:
    public class AwesomeTest {
    	public static void main(String[] args) {
    
    		int Awesome;
    
    		printLine("on a scale of 1 to 10, how awesome are you?");
    		Awesome = readInt();
    	
    		if ((Awesome < 6) && (Awesome > 1)) {
    			printLine("stop being so emo and get some self esteem. try for like, 6 or above, cause anything below five is just plain emo.");
    		}
    	
    		if ((Awesome > 6) && (Awesome < 11)) {
    			printLine("that's pretty damn awesome. seriously, you should, like, go for the world record of awesomeness...");
    		}
    
    		if (Awesome > 11) {
    			printLine("yeah, nice try buddy. nobody is that awesome. i said on a scale of one to TEN!");
    		}
    
    		if (Awesome < 1) {
    			printLine("dude, you need a therapist...");
    		}
    
    	}
    }
    by the way, the thing is supposed to ask you what your awesomeness is on a scale of 1 to ten, and reply according to what you write. i basically wrote it so i could practice with my conditionals.
    from the desk of August Underhill-Proulx, CEO of Awesomecorp ltd.

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You need to get a scanner to get input from the user. Google "java 6 scanner" for the API, also google scanner tutorial java.

    You need to open a terminal and move to the correct location of the file, compile with javac and run with java, you may have to google a tutorial of compiling and running.

  5. #5
    Zeezj's Avatar
    Zeezj is offline Member
    Join Date
    Mar 2011
    Location
    Cambridge, MA
    Posts
    11
    Rep Power
    0

    Default

    ok, i did javac, and got a lot of errors, and i think the readInt and printLine commands are supposed to be different somehow

    Java Code:
    printLine("on a scale of 1 to 10, how awesome are you?");
    		^
    AwesomeTest.java:7: cannot find symbol
    symbol  : method readInt()
    location: class AwesomeTest
    		Awesome = readInt();
    		          ^
    AwesomeTest.java:10: cannot find symbol
    symbol  : method printLine(java.lang.String)
    location: class AwesomeTest
    			printLine("stop being so emo and get some self esteem. try for like, 6 or above, cause anything below five is just plain emo.");
    			^
    AwesomeTest.java:14: cannot find symbol
    symbol  : method printLine(java.lang.String)
    location: class AwesomeTest
    			printLine("that's pretty damn awesome. seriously, you should, like, go for the world record of awesomeness...");
    			^
    AwesomeTest.java:18: cannot find symbol
    symbol  : method printLine(java.lang.String)
    location: class AwesomeTest
    			printLine("yeah, nice try buddy. nobody is that awesome. i said on a scale of one to TEN!");
    			^
    AwesomeTest.java:22: cannot find symbol
    symbol  : method printLine(java.lang.String)
    location: class AwesomeTest
    			printLine("dude, you need a therapist...");
    			^
    6 errors
    Last edited by Zeezj; 03-23-2011 at 03:49 PM.
    from the desk of August Underhill-Proulx, CEO of Awesomecorp ltd.

  6. #6
    Zeezj's Avatar
    Zeezj is offline Member
    Join Date
    Mar 2011
    Location
    Cambridge, MA
    Posts
    11
    Rep Power
    0

    Default

    anybody there?
    from the desk of August Underhill-Proulx, CEO of Awesomecorp ltd.

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    First the variable name should be awesome with a lower case a. Variable names do matter because they help keep things straight: variables and methods use camelCase while classes start with an UpperCase letter. More improtantly the variable should name the thing it is standing for: in this case awesomeness.

    Now your question...

    "cannot find symbol" is the compiler's way of saying that it doesn't know about a class, method or variable that you have mentioned. There are a variety of reasons for this (including misspelling, or getting the Case Wrong!)

    So check those methods you use - readInt() and printLine() - in the API documentation. They can be pretty hidden sometimes, so I'll give you a clue: printLine() is supposed to be in the PrintStream class. (the classes are listed on the left). Find PrintStream, look up printLine(), change it to what it should be.

    As for readInt()... Did you make it up? Or is it supposed to be a method of some class or other?

Similar Threads

  1. XML, and other things.
    By Tortex in forum New To Java
    Replies: 5
    Last Post: 03-28-2010, 06:53 PM
  2. so whats going on? (things aren't showing up)
    By Adrien in forum AWT / Swing
    Replies: 9
    Last Post: 02-20-2010, 08:22 PM
  3. Replies: 0
    Last Post: 08-26-2009, 02:03 PM
  4. A good Java installation package can make things much easier
    By freezea in forum Reviews / Advertising
    Replies: 2
    Last Post: 02-01-2009, 01:03 PM
  5. May someone explain what these things means in Java
    By quickfingers in forum New To Java
    Replies: 2
    Last Post: 01-26-2008, 06:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •