[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:Robin,
Welcome to CodeRanch!
I googled SavitchIn since that is a custom class and found this. If that's the one, you need to copy the class and put in your Eclipse project so Eclipse can find it. (Since it is in the default package, you can't import it any other way)
Oh, that is horrible code. It uses System.in.read, which is a bad method at the best of times. It also uses \n as line end, which requires a special if statement to handle line ends on a Windows® box. In the getInt method it returns -9999 as a sentinel value whi9ch is poor practice since -9999 might be a valid input.Jeanne Boyarsky wrote:. . . I googled SavitchIn since that is a custom class and found this. . . .
Zachary Griggs wrote:It sounds like you'll need to create a new external class named "SavitchIn", and copy all the code in there. But what advantage does this offer over Scanner?
No.Robin Leckey wrote:If I used JCreator, would my problem be solved? . . .
Campbell Ritchie wrote:
No.Robin Leckey wrote:If I used JCreator, would my problem be solved? . . .
I still think that class you found should be deleted. Why are you using nextLineInt? Either a method returns a line or it returns an int; it won't return both, so you are not going to find a method like nextLineInt in any input program.
No it isn't. It says readLineInt on that pdf.Robin Leckey wrote:. . . nextLineInt(); is allowed.
Campbell Ritchie wrote:
No it isn't. It says readLineInt on that pdf.Robin Leckey wrote:. . . nextLineInt(); is allowed.
Campbell Ritchie wrote:Please tell us which directory the .java and .class files are in, and also what your CLASSPATH is:-
echo %CLASSPATH%
on Windows
or
echo $CLASSPATH
on Linux.
Liutauras Vilda wrote:Hi Robin,
Somehow we went deeply into technical details rather than discussing what is your chosen way to solve an exercise. Don't you want to share with us what is the project about you're working on?
Usually such example code snippets quite easily could be found on Oracle tutorials or by looking similar question using our topics search option, but first you need to know what to look for.
My question is, did you solve your project exercise in your head and documented on a piece of paper?
No, think about jdk as about a program, which is called java development kit. This program gives you an ability to compile and run your written java source files, which ends *.java. Once you compile your *.java file with java compiler - they become *.class file/-s.Robin Leckey wrote:I'm not sure if this is right, but wouldn't the .java files and the .class files be in the jdk under my C drive? I really don't know
Liutauras Vilda wrote:
No, think about jdk as about a program, which is called java development kit. This program gives you an ability to compile and run your written java source files, which ends *.java. Once you compile your *.java file with java compiler - they become *.class file/-s.Robin Leckey wrote:I'm not sure if this is right, but wouldn't the .java files and the .class files be in the jdk under my C drive? I really don't know
So, usually your source files would be somewhere else from your jdk instalation directory. They could be anywhere. If you used Eclipse, upon Eclipse install it gives you to choose default location where your all project files will be located, default option if I remember is given as "workspace" in your prefered logical operation system drive: could be C:\ ; D:\
Well, I never used JCreator, nor seen it. Campbell seen it, but unfortunately he can't remember.Robin Leckey wrote:I really don't want to use NotePad because the programming classes at my school use JCreator. I know how to program. I'm just so confused on how to set JCreator up. But your instructions are helpful so far. I kind of understand.
Liutauras Vilda wrote:Look up on youtube how to write programs using plain text editor rather than clever programming environments - these could be too difficult at the very beginning.
Look on youtube things as:
1. Write Java programs with NotePad++
2. Compile Java programs from Windows command line
3. Run Java programs from Windows command line
Also, please show us what shows you when you type in command line (windows + r; cmd; enter) %PATH%
Liutauras Vilda wrote:I was mistaken in giving instructions, forgot to type echo %PATH%, sorry.
But from the other your executed command cna be seen, that all good with PATH variable. Now try to write echo %CLASSPATH% (what Campbell Ritchie suggested you earlier).
Liutauras Vilda wrote:
Well, I never used JCreator, nor seen it. Campbell seen it, but unfortunately he can't remember.Robin Leckey wrote:I really don't want to use NotePad because the programming classes at my school use JCreator. I know how to program. I'm just so confused on how to set JCreator up. But your instructions are helpful so far. I kind of understand.
Anyway, lets do it simple. Delete any programming project you created within the JCreator environment and try to create a new fresh one. Create a project with one file which is called Test and copy n' paste the code below and try to execute it.
Earlier I wrote wrote:try to write echo %CLASSPATH% (what Campbell Ritchie suggested you earlier)
Liutauras Vilda wrote:
Earlier I wrote wrote:try to write echo %CLASSPATH% (what Campbell Ritchie suggested you earlier)
Liutauras Vilda wrote:Expand "src" folder, until you see "test.java" file. Then right mouse click on it, and select run/execute or similar.
Liutauras Vilda wrote:Clear!
That is because you created file Test.java (T upper) and inside the file you declared class as test (lower case). Inside the file make it:
As I said earlier, copy and paste, it seems you decided to rewrite and made a mistake.