1

I' am using java jdk1.8.0_05. In the project i get an error as 'The type java.nio.CharBuffer cannot be resolved. It is indirectly referenced from required .class files' in the line:

new FileReader(filename).read(buffer);

How to solve this.

User1100
  • 45
  • 4
Gokul
  • 105
  • 2
  • 6
  • 16
  • Check your referenced libraries in project setup -- whenever I get something like this (usually for me it's `java.lang.Object` that can't be resolved) I find that the JRE System Library is mysteriously missing – awksp May 13 '14 at 06:56
  • I have JRE System Library [jdk1.8.0_05] referenced. – Gokul May 13 '14 at 07:02
  • Could you go into the JRE System Library and verify that the `.class` file is actually there? And/or remove the JRE System Library, save, then add it again? – awksp May 13 '14 at 07:03
  • I removed the JRE System Library and added it once gain. But, the issue is not solved. – Gokul May 13 '14 at 08:19
  • Did you add it immediately after removing it, or did you close out of the preferences window after removing? – awksp May 13 '14 at 08:22
  • I tried it both ways. First i removed the JRE library from Java build path and added it immediately. Then, i removed the JRE library from Java Build path. Closed the properties window and added it again. – Gokul May 13 '14 at 08:25
  • Interesting... What about moving your files to a new project? – awksp May 13 '14 at 08:29
  • 1
    I removed jdk1.8.0_05 and put back jdk1.7.0_55. Now its working. Wasn't able to make it work with jdk1.8.0_05. – Gokul May 13 '14 at 10:35
  • Odd. `CharBuffer` definitely exists in JDK 1.8.0_05... Did you look for the .class file in the library? – awksp May 13 '14 at 10:39
  • Please post the output of 'java -version'. – user207421 May 13 '14 at 21:29

5 Answers5

1

Eclipse is out of date. The old version that produce the errors is eclipse "Helios". I tried the most recent version Eclipse "Mars" and the build passed.

Henrik Sachse
  • 51,228
  • 7
  • 46
  • 59
thtfpcuser
  • 11
  • 1
0

I was experiencing the same issue with a recently ported project. My situation was that I installed the newest version of Java on startup and attached it to my previous projects. There was some other minor issues that I fixed but this was not one of them. I found that according to the website, all of the documentation was available, the class was part of my install, however was not found.

I eventually fixed this by just reverting back to JDK1.7. Fixed my problem instantly, but I would love a little more attention and a better answer then changing back versions.

Sh4d0wsPlyr
  • 948
  • 12
  • 28
0

I was also experiencing this with the Hive Web Interface with the war file hive-hwi-0.12.0.war.

General solution: Locate the new FileReader(filename).read(buffer) statement in the java/jsp code. The method read() with 1 parameter (in this case buffer) is somehow not supported in the "lower" java 1.8 versions. Instead of passing 1 parameter, 3 parameters should be passed: buffer, offset and bufferlength. Change the statement in "new FileReader(filename).read(buffer,0,buffer.length);"

For Hive Web Interface in file view_file.jsp change statement "cread=br.read(c)" into "cread=br.read(c,0,c.length)".

khaga
  • 11
  • 1
0

I realize this comes a bit late, but it's not marked as solved, so I'll share.

I had this experience with java.nio.FloatBuffer in a clean install of Ubuntu 15.04, using OpenJDK 8. You didn't specify which OS you're using, so here's what fixed it for me:

Install the openjdk-7-jre-lib package; e.g. sudo apt-get install openjdk-7-jre-lib

Note that there's no openjdk-8-jre-lib package in the default list of repositories.

This assumes you have your build path properly configured. See this SO post for more info on that.

code_dredd
  • 5,915
  • 1
  • 25
  • 53
-1

I am using eclipse mars first we need to check the Jre installed libraries and build them,after that clean u r project now the problem is resolved.

Adhi
  • 1