Java problems in Linux mint

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Feline

Java problems in Linux mint

Post by Feline »

Hi,

This is not exactly a problem that has something to do with Linux Mint. However, I would need help and I thought someone else might have faced the same problem in here.

When I try to run my java application in eclipse I get the following error message: 'Scanner cannot be resolved to a type'. (In the Java application I'm building, I'm using the Scanner-class from the package java.util to read input from keyboard).

The problem should not be my JRE, cause I have openjdk-6-jdk installed and it should contain the appropriate jre (1.5 or higher), right? Question is, how could I tell Eclipse that it should use the right JRE. I suppose it's trying to use a wrong run-time environment. I tried the same application in eclipse windows and didn't have this kind of problems. So what's the matter? Anyone know?

I would be really glad if someone could help me, cause I want to use my Linux Mint installation for my Java projects and this problem is ruining my Linux experience, which otherwise has been really great :(
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Kaye

Re: Java problems in Linux mint

Post by Kaye »

To check if it's an Eclipse problem:

Code: Select all

javac /path/to/.java file
If it compiles correctly in this way, then it is an Eclipse path issue. Otherwise, trying installing the latest JDK (even though it appears you've already done so).
Feline

Re: Java problems in Linux mint

Post by Feline »

Thanks. Yep, I've already tried that before trying to run the same java application in eclipse. it compiles all right if I do it from the terminal. I could of course just do all the script writing in a text editor and compile the programs in the terminal, but I'm interested to get eclipse working.

Strangely enough I get the exactly same error message, when I try to compile my applications with eclipse in ubuntu. Also in this situation, the compiling works all right in the terminal. I also tried NetBeans and get exactly the same error message. It's really strange.

I suppose it's an eclipse/netbeans problem, but I strangely enough do not have these problems, when I'm using eclipse or netbeans in windows.
Feline

Re: Java problems in Linux mint

Post by Feline »

So, how could I tell eclipse, that it should use the correct runtime environment that is installed on my OS?

Anyone know? If someone does, I'm really glad if you tell me how to do this.
gcampton

Re: Java problems in Linux mint

Post by gcampton »

I would think this is a PATH issue, possibly eclipse/options is not pointing to all the default paths?
Other than that, I would say it's open-JDK, which seems to always cause problems, if your not an avid open source junkie, then remove it and install the latest sun-java-SDK...
Feline

Re: Java problems in Linux mint

Post by Feline »

I would do that, but I don't know how to check whether Eclipse is pointing to all the correct paths. I'm quite new to eclipse IDE. The problem might the open-jdk, so I'll try to change that next. However on my other computer I have sun-java6-jdk installed and have exactly the same problem, so it really might an eclipse PATH issue.

Thanks for help anyway! :D
Mocha

Re: Java problems in Linux mint

Post by Mocha »

well i usually use jdeveloper, but I installed eclipse it and compiled without any problems. But having a look around i couldn't see any options for eclipse itself only for a a specific project.
But you should be able to go into Project-properties-Java Build Path and set it from there.
Feline

Re: Java problems in Linux mint

Post by Feline »

Yeah, I also didn't find any options that would enable me to set eclipse to generally point to a certain JRE.

I know you can set the JRE for any single project and I noticed that my project is using a JRE library that's something like java 1.5.0. I suppose this is the problem. I however still have no idea how I could get my projects to point at the correct JRE.

Well, maybe I'll give a try to jdeveloper then. Or then I'll just remove eclipse and install it again. I tried my application in NetBeans and it compiled all right, so eclipse is apparently the problem.

Still if somebody knows the answer to this problem, I'm really grateful if you'll tell it to me too.
Feline

Re: Java problems in Linux mint

Post by Feline »

Ok, I found out that the problem is eclipse. It is using a default JRE called java-1.5.0-gcj-4.3-1.5.0.0. Surprisingly, this jre doesn't seem to contain the Scanner class (???). I have JRE 1.6 installed, but somehow eclipse is not capable of finding it. Neither can I find it, when I try to change to build path for individual projects.

When compiled from command line, all my applications work fine with no problems, but I can't get eclipse in Linux to understand that it should use the friggin JRE 1.6, which is the JRE installed in my system, and not some of it's own default JRE. I would still like to use an IDE for my java-projects, cause they make the building of projects so much easier.

In windows, this all works fine, which is pretty depressing, cause otherwise Linux provides so many great tools that I would like to use for my projects. I wouldn't want to transfer all my java projects in windows. Are there experienced Linux users who could help me solve this problem? :?: If you can help me, I'll really be overjoyed :D

It's just stupid and frustrating that I can't get eclipse to co-operate with my system. I also tried NetBeans and it compiles my applications, but doesn't run them. I only get an output saying something like 'compiling succesful'. Sigh... :(
Kaye

Re: Java problems in Linux mint

Post by Kaye »

Ok.. the thing that really sticks out from your last post is that writing java means you're using the JDK, not the JRE (which is a huge difference).
Feline

Re: Java problems in Linux mint

Post by Feline »

Yes, I have the latest JDK by Sun Microsystems installed on my system and included in this JDK is the runtime environment 1.6.0_10. The problem is that eclipse doesn't seem to notice that my system has the newest runtime environment. Even stranger is the fact the JRE 1.5. that eclipse is using should include the Scanner class (?!) But no, I can't get it working.

Does anyone in the world know, what the problem is? :D Removing and installing eclipse again does not work.
gcampton

Re: Java problems in Linux mint

Post by gcampton »

Feline wrote:Yes, I have the latest JDK by Sun Microsystems installed on my system and included in this JDK is the runtime environment 1.6.0_10. The problem is that eclipse doesn't seem to notice that my system has the newest runtime environment. Even stranger is the fact the JRE 1.5. that eclipse is using should include the Scanner class (?!) But no, I can't get it working.

Does anyone in the world know, what the problem is? :D Removing and installing eclipse again does not work.
Sorry I can't be more of a help, but in this section where you see it using the JRE, try to change it to the /usr/bin/jdk path I'm not sure of the actual path you can find it by typing /which JDK, or /type -a jDK
maybe /type -a sun-jdk-1.6.0_10
just fiddle around till you find the correct name for it. /which and /type will tell you where it's installed.
(you may want to install the latest build to i think it's up to 1.6.0_18 and there's a 1.7.0 in dev downloads)

Failing that you need to switch to something else:
a) basic java IDE "GEANY" geany is a very lightwieght java ide good for beginner students, as you can create single java files easily and just hit the build/run button. Also has options for Projects.
b) serious java IDE "NETBEANS" which I'm sure you have tried before or at least heard of, which Netbeans can seem a bit daunting it really is the IDE you want to be able to use long term.
deleted

Re: Java problems in Linux mint

Post by deleted »

Install the jdk from synaptic. That way all the links, etc, that Debian wants will be in the right place... and Eclipse can find everything. I've found that if you work with the system, everything goes much smoother.
gcampton

Re: Java problems in Linux mint

Post by gcampton »

hinto wrote:Install the jdk from synaptic. That way all the links, etc, that Debian wants will be in the right place... and Eclipse can find everything. I've found that if you work with the system, everything goes much smoother.
yep...

or configure --prefix=/the correct path when installing :P
gcampton

Re: Java problems in Linux mint

Post by gcampton »

Ok I decided I have had enough of Jcreator on windows and all the admin over at javaforums say they prefer eclipse over Netbeans. So I downloaded clicked preferences -> java -> installed JRE's changed path it was set to my snapshot build of JRE7, so stuck it back to JRE6 as the error symbols are a little more complete. Can't find where to set JDK options though... I assume I probably won't need to anyway, I have java path in set in environment paths. Lots of little extras in eclipse that make it more worthwhile than Netbeans I have been told, so I recant all my previous comments ^^. Such as having say you class as a different name to your file, while Both IDE's yell at you for this, Eclipse has a feature where you can hover over the class name and either change the class name and all instances that use it to the filename with 1 click of a button, or change the filename to the class name with a click, while Netbeans expects you to do it manually :evil:
Feline

Re: Java problems in Linux mint

Post by Feline »

Many thanks for all of your replies! :D They have been a great help at least for getting me to know Linux Mint a little better.

I'll see if some of the solutions you mentioned could solve my problem. (I'm getting tired of windows Vista and really want to take my Java projects to Linux).

I'll get back to this. Hopefully I've got the Java running properly at that time.
Feline

Re: Java problems in Linux mint

Post by Feline »

Thanks for all your replies! :D I've tried to install java JDK using synaptic, but it didn't work. The applications won't compile correctly even when I just run them in the terminal. I always get the same error: "Class Scanner cannot be resolved to a type". This is really strange, cause I've tried this in Ubuntu and it works fine both in the terminal and in eclipse. So, I probably have to take my Java projects to Windows Vista, which is a shame, since Mint works really well with everything else (and Windows Vista doesn't...).

I also like the clear intuitive UI of Mint, so I'm really hoping someone could tell me what is wrong. Perhaps a Linux Mint expert or forum moderator?

But anyway, thanks a lot for the replies and for spending your time to help me find a solution! :D
gcampton

Re: Java problems in Linux mint

Post by gcampton »

Lolz, yea......

I'm having your exact problem only in windows, have path environment set for jdk and cygwin, and yet eclipse is giving me a ton of errors, saying it can't autobuild etc.
I have gone through the tutorials and options reset some values as it was using the beta jre 7.0 --> changed back to jre 6.1x and no luck.
deleted

Re: Java problems in Linux mint

Post by deleted »

Did you install the .deb or unzip the jdk?
If you install the deb, then all the appropriate links are set. If you unzip the jdk, then you'll have to set JAVA_HOME.
-H
Feline

Re: Java problems in Linux mint

Post by Feline »

Ok, it's kinda good to see, I'm not the only one facing java compiling problems. Yeah, I haven't had this kind of problems in Linux before. In windows I've had these occasionally.
So far I have tried to install the JDK both by typing 'sudo apt-get install JDK-name' in terminal and by installing it via Synaptics. It's crazy. It's not working no matter which way I try to install it. I don't understand it. I've had no java problems like this in any other system except Linux Mint. It sucks cause I like Linux Mint. '

How do you set JAVA_HOME? By typing it in terminal?
Locked

Return to “Software & Applications”