5 Replies - 2954 Views - Last Post: 11 April 2012 - 04:36 AM Rate Topic: -----

#1 Quint   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-April 12

'class, interface, or enum expected', not sure what ive done w

Posted 11 April 2012 - 04:13 AM

Hey, i am new to Java and this is one of my first real projects, its a bot script for a game. For some reason i keep getting the 'class, interface, or enum expected' error when compiling. Although i know what this means and i know how to fix it, i cant seem to find what ive done wrong... Please share your insight into what i need to do to fix it. Searched on google, but still couldnt find it.

package scripts;

import bot.ScriptMethods;

public class Slycutter extends ScriptMethods implements Runnable {
//-------------------------------------------------------------------------------------------------//
//
//            
//			          
//       
//	    			  
//   
//			
//
//-------------------------------------------------------------------------------------------------//
	public Thread scriptThread;
	public boolean scriptRunning = false;
	public void start() {
		getAccountSettings();
		System.gc();
		scriptRunning = true;
		scriptThread = new Thread(this);
		scriptThread.start();
	
//-------------------------------------------------------------------------------------------------//
	}
	public void stop(); {
		System.gc();
		scriptRunning = false;
		debug("Stopped script.");
	}
//-------------------------------------------------------------------------------------------------//
	public void run(); {
		while (scriptRunning) {
			try {
				handleEvents();
				int[] tree = getObjectById(1);
				int[] tree2 = getObjectById(0);
				int[] tree3 = getObjectById(70);
				if (!isSleeping()) {
//-------------------------------------------------------------------------------------------------//
					if (tree[0] != -1) {
						atObject(tree[1], tree[2]);
						wait(random(600, 1000));
//-------------------------------------------------------------------------------------------------//
					} else if (tree2[0] != -1) {
						atObject(tree2[1], tree2[2]);
						wait(random(600, 1000));
//-------------------------------------------------------------------------------------------------//
					} else if (tree3[0] != -1) {
						atObject(tree3[1], tree3[2]);
						wait(random(600, 1000));
//-------------------------------------------------------------------------------------------------//
					} else {
						wait(200);
					}
				}

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
//-------------------------------------------------------------------------------------------------//
	public void handleEvents() throws Exception; {
		if (welcomeBoxOpen())
			setWelcomeBox();
		if (!isLoggedIn())
			doLogin();
		if (getFatigue() > 80 && !isSleeping()) {
			wait(600);
			useItem(1263);
			wait(600);
//-------------------------------------------------------------------------------------------------//	
	     }
		if (getFatigueSleeping() < 10 && isSleeping())
			doSleeping();
		if (getFightMode() != fightMode)
			setFightMode();
	}
    }
  
}

//-------------------------------------------------------------------------------------------------//




Compile information.

Parsing Input...

Compiling...

Standard Output from javac:

/tmp/jc_12694/Slycutter.java:83: class, interface, or enum expected
}
^
1 error
Output File(s)

No Output File created


Is This A Good Question/Topic? 0
  • +

Replies To: 'class, interface, or enum expected', not sure what ive done w

#2 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2770
  • View blog
  • Posts: 4,429
  • Joined: 21-June 11

Re: 'class, interface, or enum expected', not sure what ive done w

Posted 11 April 2012 - 04:16 AM

You've got one closing curly brace too many.
Was This Post Helpful? 0
  • +
  • -

#3 karabasf   User is offline

  • D.I.C Regular
  • member icon

Reputation: 202
  • View blog
  • Posts: 417
  • Joined: 29-August 10

Re: 'class, interface, or enum expected', not sure what ive done w

Posted 11 April 2012 - 04:19 AM

I think you have a bracket too much ;)

Remove the bottom one and see what it does. (The last bracket does not match with any open bracket, so that's my reason to suspect that that's the culprit)

Good luck! ^^
Was This Post Helpful? 0
  • +
  • -

#4 Quint   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-April 12

Re: 'class, interface, or enum expected', not sure what ive done w

Posted 11 April 2012 - 04:26 AM

Thats what i thought too, however when i delete it i get heaps of different errors... and when it go's back in i only get the one. Can you show me what part exactly, i might be removing the wrong one or somthing...

/tmp/jc_1281/Slycutter.java:3: package bot does not exist
import bot.ScriptMethods;
          ^
/tmp/jc_1281/Slycutter.java:5: cannot find symbol
symbol: class ScriptMethods
public class Slycutter extends ScriptMethods implements Runnable {
                               ^
/tmp/jc_1281/Slycutter.java:19: cannot find symbol
symbol  : method getAccountSettings()
location: class scripts.Slycutter
		getAccountSettings();
		^
/tmp/jc_1281/Slycutter.java:22: cannot find symbol
symbol  : constructor Thread(scripts.Slycutter)
location: class java.lang.Thread
		scriptThread = new Thread(this);
		               ^
/tmp/jc_1281/Slycutter.java:27: missing method body, or declare abstract
	public void stop(); {
	            ^
/tmp/jc_1281/Slycutter.java:30: cannot find symbol
symbol  : method debug(java.lang.String)
location: class scripts.Slycutter
		debug("Stopped script.");
		^
/tmp/jc_1281/Slycutter.java:33: missing method body, or declare abstract
	public void run(); {
	            ^
/tmp/jc_1281/Slycutter.java:37: cannot find symbol
symbol  : method getObjectById(int)
location: class scripts.Slycutter
				int[] tree = getObjectById(1);
				             ^
/tmp/jc_1281/Slycutter.java:38: cannot find symbol
symbol  : method getObjectById(int)
location: class scripts.Slycutter
				int[] tree2 = getObjectById(0);
				              ^
/tmp/jc_1281/Slycutter.java:39: cannot find symbol
symbol  : method getObjectById(int)
location: class scripts.Slycutter
				int[] tree3 = getObjectById(70);
				              ^
/tmp/jc_1281/Slycutter.java:40: cannot find symbol
symbol  : method isSleeping()
location: class scripts.Slycutter
				if (!isSleeping()) {
				     ^
/tmp/jc_1281/Slycutter.java:43: cannot find symbol
symbol  : method atObject(int,int)
location: class scripts.Slycutter
						atObject(tree[1], tree[2]);
						^
/tmp/jc_1281/Slycutter.java:44: cannot find symbol
symbol  : method random(int,int)
location: class scripts.Slycutter
						wait(random(600, 1000));
						     ^
/tmp/jc_1281/Slycutter.java:47: cannot find symbol
symbol  : method atObject(int,int)
location: class scripts.Slycutter
						atObject(tree2[1], tree2[2]);
						^
/tmp/jc_1281/Slycutter.java:48: cannot find symbol
symbol  : method random(int,int)
location: class scripts.Slycutter
						wait(random(600, 1000));
						     ^
/tmp/jc_1281/Slycutter.java:51: cannot find symbol
symbol  : method atObject(int,int)
location: class scripts.Slycutter
						atObject(tree3[1], tree3[2]);
						^
/tmp/jc_1281/Slycutter.java:52: cannot find symbol
symbol  : method random(int,int)
location: class scripts.Slycutter
						wait(random(600, 1000));
						     ^
/tmp/jc_1281/Slycutter.java:55: cannot find symbol
symbol  : method wait(int)
location: class scripts.Slycutter
						wait(200);
						^
/tmp/jc_1281/Slycutter.java:65: missing method body, or declare abstract
	public void handleEvents() throws Exception; {
	            ^
/tmp/jc_1281/Slycutter.java:66: cannot find symbol
symbol  : method welcomeBoxOpen()
location: class scripts.Slycutter
		if (welcomeBoxOpen())
		    ^
/tmp/jc_1281/Slycutter.java:67: cannot find symbol
symbol  : method setWelcomeBox()
location: class scripts.Slycutter
			setWelcomeBox();
			^
/tmp/jc_1281/Slycutter.java:68: cannot find symbol
symbol  : method isLoggedIn()
location: class scripts.Slycutter
		if (!isLoggedIn())
		     ^
/tmp/jc_1281/Slycutter.java:69: cannot find symbol
symbol  : method doLogin()
location: class scripts.Slycutter
			doLogin();
			^
/tmp/jc_1281/Slycutter.java:70: cannot find symbol
symbol  : method getFatigue()
location: class scripts.Slycutter
		if (getFatigue() > 80 && !isSleeping()) {
		    ^
/tmp/jc_1281/Slycutter.java:70: cannot find symbol
symbol  : method isSleeping()
location: class scripts.Slycutter
		if (getFatigue() > 80 && !isSleeping()) {
		                          ^
/tmp/jc_1281/Slycutter.java:71: cannot find symbol
symbol  : method wait(int)
location: class scripts.Slycutter
			wait(600);
			^
/tmp/jc_1281/Slycutter.java:72: cannot find symbol
symbol  : method useItem(int)
location: class scripts.Slycutter
			useItem(1263);
			^
/tmp/jc_1281/Slycutter.java:73: cannot find symbol
symbol  : method wait(int)
location: class scripts.Slycutter
			wait(600);
			^
/tmp/jc_1281/Slycutter.java:76: cannot find symbol
symbol  : method getFatigueSleeping()
location: class scripts.Slycutter
		if (getFatigueSleeping() < 10 && isSleeping())
		    ^
/tmp/jc_1281/Slycutter.java:76: cannot find symbol
symbol  : method isSleeping()
location: class scripts.Slycutter
		if (getFatigueSleeping() < 10 && isSleeping())
		                                 ^
/tmp/jc_1281/Slycutter.java:77: cannot find symbol
symbol  : method doSleeping()
location: class scripts.Slycutter
			doSleeping();
			^
/tmp/jc_1281/Slycutter.java:78: cannot find symbol
symbol  : method getFightMode()
location: class scripts.Slycutter
		if (getFightMode() != fightMode)
		    ^
/tmp/jc_1281/Slycutter.java:78: cannot find symbol
symbol  : variable fightMode
location: class scripts.Slycutter
		if (getFightMode() != fightMode)
		                      ^
/tmp/jc_1281/Slycutter.java:79: cannot find symbol
symbol  : method setFightMode()
location: class scripts.Slycutter
			setFightMode();
			^
34 errors

Was This Post Helpful? 0
  • +
  • -

#5 karabasf   User is offline

  • D.I.C Regular
  • member icon

Reputation: 202
  • View blog
  • Posts: 417
  • Joined: 29-August 10

Re: 'class, interface, or enum expected', not sure what ive done w

Posted 11 April 2012 - 04:30 AM

Well, the question here is (as I look at your bug report), is the package bot in the project folder?

It seems that that package is actually missing.
Was This Post Helpful? 1
  • +
  • -

#6 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2770
  • View blog
  • Posts: 4,429
  • Joined: 21-June 11

Re: 'class, interface, or enum expected', not sure what ive done w

Posted 11 April 2012 - 04:36 AM

You removed the right one. Just because the number of compiler errors increased doesn't mean you didn't move in the right direction. As long as you have syntax errors in your code, the compiler can't do any further checks, so you won't get type errors and other semantic errors as long as the syntax is wrong. So once you fixed all syntax errors, the semantic errors pop up, which can often lead to a large increase in error messages when fixing syntax errors. That's perfectly normal.

This post has been edited by sepp2k: 11 April 2012 - 04:37 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1