Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Throw IOException not compiling
Throw IOException not compiling [message #1384957] Tue, 03 June 2014 09:53 Go to next message
Michal Burgunder is currently offline Michal BurgunderFriend
Messages: 3
Registered: June 2014
Junior Member
Hello,

I am currently working through a Java Beginners Guide (5th edition on amazon, should popo right out), so I have downloaded the Java development Kit, and also the Eclipse program. And I've stumbled upon a problem:

public class KbIn {
	public static void main(String args[])	{
		throws IOException;	{
			
			char ch;
			
			System.out.print("Press a key followed by Enter: ");;
			
			ch = (char) System.in.read();
			System.out.println("Your key is: " + ch);
		}
	}
}

The book tells me that this code should compile, but I get a "IOException cannot be resolved to a variable" error. How do I fix this issue?

Best,
Michal
Re: Throw IOException not compiling [message #1385003 is a reply to message #1384957] Tue, 03 June 2014 14:41 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Hint: curly braces are relevant symbols.
Re: Throw IOException not compiling [message #1385065 is a reply to message #1385003] Wed, 04 June 2014 07:19 Go to previous messageGo to next message
Michal Burgunder is currently offline Michal BurgunderFriend
Messages: 3
Registered: June 2014
Junior Member
Thanks for the reply, I greatly appreciate it.

I've tried out the curly braces in several different places, but still cannot seem to get it working. Note, I am very much a beginner at Eclipse/coding in general, so as far as I understand Java, having something not resolved to a variable depends on defining one beforehand, not necessarily curly braces.
Re: Throw IOException not compiling [message #1385133 is a reply to message #1385065] Wed, 04 June 2014 13:54 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 04/06/2014 09:19, Michal Burgunder wrote:
> Thanks for the reply, I greatly appreciate it.
>
> I've tried out the curly braces in several different places, but still
> cannot seem to get it working. Note, I am very much a beginner at
> Eclipse/coding in general, so as far as I understand Java, having
> something not resolved to a variable depends on defining one beforehand,
> not necessarily curly braces.

The Java Tutorial is excellent. Compare what you have with what they
have:
http://docs.oracle.com/javase/tutorial/essential/exceptions/declaring.html



Good luck :p
Re: Throw IOException not compiling [message #1385285 is a reply to message #1385133] Thu, 05 June 2014 11:56 Go to previous message
Michal Burgunder is currently offline Michal BurgunderFriend
Messages: 3
Registered: June 2014
Junior Member
Okay, finally got it. Thanks! Smile
Previous Topic:Compiling .class file for Eclipse 3.4.1
Next Topic:eclipse randomly renames package
Goto Forum:
  


Current Time: Thu Jun 13 01:01:56 GMT 2024

Powered by FUDForum. Page generated in 0.04328 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top