Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » linking TextIO to Eclipse Java Project(Cannot get Eclipse to recognize TextIO)
linking TextIO to Eclipse Java Project [message #821835] Thu, 15 March 2012 21:55 Go to next message
Brian Case is currently offline Brian CaseFriend
Messages: 3
Registered: March 2012
Junior Member
Hope this is the right forum. This should have taken three minutes and I've lost the whole day on this.

I'm running Eclipse Eclipse SDK Version: 3.7.2 with the default workspace on C:\Documents and Settings\owner\workspace on windows xp. I'm using the jdk-7u3-windows-i586 version of Java.

Separately, I've downloaded TextIO.java (and in desperation even created a class for it). I've copied and pasted TextIO.java to every place I can think of, but the Eclipse IDE does not find it.

e.g. Here's the code for the class (and project) (periods used to show indents)
public class Exercise1v1 {
....public static void main(String[] args) {
.
........String usersName; // The user's name, as entered by the user.
........String upperCaseName; // The user's name, converted to upper case letters.
.
........System.out.print("Please enter your name: ");
........usersName = TextIO.getln();
.
........upperCaseName = usersName.toUpperCase();
.
........System.out.println("Hello, " + upperCaseName + ", nice to meet you!");

.....} // end main()

}

the error is "the method getln() is undefined for the type TextIO"

My Project is
Exercises1
..- src
....- default package
....- Exercise1v1,java
....- TextIO.java
..+ snippet
..+ JRE System Library [JavaSE 1.7]
....TextIO.java
Re: linking TextIO to Eclipse Java Project [message #821895 is a reply to message #821835] Thu, 15 March 2012 23:50 Go to previous messageGo to next message
Brian Case is currently offline Brian CaseFriend
Messages: 3
Registered: March 2012
Junior Member
Resolved. Terminology issue.

The TextIO.java goes on the project group, not the package.
Re: linking TextIO to Eclipse Java Project [message #1799133 is a reply to message #821835] Fri, 30 November 2018 10:22 Go to previous message
Enda McCabe is currently offline Enda McCabeFriend
Messages: 1
Registered: November 2018
Junior Member
For those of you foloowing a course that uses import textio.TextIO as you have discovered, this will not work in Eclipse.

There is a simple way around this.

Instead of importing textio.TextIO you can import Scanner.

So all you do is at the start of your program replace:
import textio.TextIO;
with import java.util.Scanner;

in the "main" enter the following code

Scanner scan = new Scanner( System.in );


And where TextIO is used amend the code.

Here are a couple of examples. (usersGuess is an integer and playAgain a boolean)

usersGuess = TextIO.getInt();
becomes usersGuess = keyboard.nextInt();

playAgain = TextIO.getlnBoolean();
becomes playAgain = keyboard.nextBoolean();

I hope this helps.

[Updated on: Fri, 30 November 2018 15:37]

Report message to a moderator

Previous Topic:no folder named 'all'
Next Topic:HTTPS to HTTP cookie issue
Goto Forum:
  


Current Time: Thu Feb 20 14:34:53 GMT 2020

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

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

Back to the top