why is Scanner class of java not working on fedora 7
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
why is Scanner class of java not working on fedora 7
i have installed JDK 1.6 on my fedora 7 , all my java programs are running fine except for those that use Scanner class uner UTIL package.
it says "cannot resolve to a type" , i checked and found that Scanner class is there where jdk is placed under /usr/java/jdk1.6/src/java/util
is there some problem in class or what because everything else is running fine.
note*:i am using fedora under vmvare.
What program/process is it that's giving you the "cannot resolve to a type" error - is it through Netbeans or Eclipse, or is it through trying to compile from the command line?
I have Java 6 (1.6) installed from the sun-java6-jdk package in Debian, and I don't have any problems with the java.util.Scanner class - I use it for practically anything I/O related (as a reader). The only time I have ever had an issue with it was when I compiled it with "javac" and tried to run it with "java" while I had GCJ installed - under Debian, the "java" command associated with GCJ takes precedence over Sun's "java" command. The GCJ implementation does not have the java.util.Scanner class (which is bogus).
Make sure, when you're running it, if you're trying to do so from the command line, that you're not accidentally invoking the GCJ "java"; to check this, if you have both GCJ and Sun Java installed is to run "java -version".
If you're getting this from an IDE, tell us which IDE, and I can try and help you figure out what the issue may be.
Some weird things I've noticed, is that something may compile perfectly fine under GCJ, but not run afterwards, and it would give me errors like the one you've listed above (either after a native, or bytecode, compilation).
Since the command to compile stuff with GCJ is - oddly enough - "gcj", we don't need to worry about the "javac" command being doubled - however, the GCJ package does supply a "java" command, which is troublesome.
To isolate the Sun Java RE:
1. In a console, run
Code:
$ which javac
and it should give you something like "/usr/lib/jdk1.6/bin/javac". It will probably be different, but you never know. Just take note of the path before the "javac".
2. Open up your text editor of choice, and open your .bashrc file (located in your home directory - "~"). Anywhere in the file, add the following:
Code:
alias java='/usr/lib/jdk1.6/bin/java'
3. Back in a terminal, source your update .bashrc:
Code:
$ source ~/.bashrc
Sun supplies all of its Java-centric tools in one directory, which is really nice, so the location of the Java "javac" compiler, will also have the "java" runtime environment in it. Alternately, instead of "java" being the name of the alias, you could use "sun-java" or whatever you prefer.
Although GCJ is a piece of crap, I think it's neat that I can write basic Java programs and compile them to native code. I prefer Java to C and C++ when it comes to GUI programming, hence I find the GCJ project interesting, but it is still WAY too young for any sort of production use.
i have updated the bashrc file with that alias command , and also executed that source command , but still that same error is coming , i think the jdk java is not invoked still
The GCJ package doesn't ship with a "javac" command, though - the GCJ-equivalent is the "gcj" command. It does, however, ship with a "java" command. Is it running it, or compiling it that is providing the error?
I wasn't joking. I'd seriously consider de-installing GJC until you're thoroughly comfortable using the Sun JDK. It will be *much* easier to get things working. You can always re-install GJC again later, if you want it.
I'm definitely in full agreement with paulsm4, here. Just flat-out uninstall GCJ and see if the problem corrects itself. If all else fails, uninstall both GCJ and the Sun JDK, download the latest binary installer from http://java.sun.com/ and install from that - that will be guaranteed to work.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.