2

I'm using Eclipse as IDE on RHEL 6.5 with JDK 1.8

When I try to declare some object of JTable, it doesn't find appropriate import package/class.

When I manually try to write import statement, it only shows up to javax.swing, but it doesn't show JTable there after.

import javax.swing.JTable;

public class JTableTest {

    public static void main(String args[]) {
        JTable obj1 = new JTable();
    }
}

it only happens when using JTable other imports are not affected...

enter image description here

Martin Frank
  • 3,445
  • 1
  • 27
  • 47
bhushan
  • 46
  • 1
  • 5
  • Perhaps post your code? The [javadoc](http://docs.oracle.com/javase/8/docs/api/javax/swing/JTable.html) says JTable is under javax.swing, so it's definitely something silly. – hd1 Sep 10 '14 at 08:58
  • is it possible to check if my jdk contains JTable or not? – bhushan Sep 10 '14 at 09:03
  • import javax.swing.JTable; public class JTableTest { public static void main(String args[]) { JTable obj1 = new JTable(); } } – bhushan Sep 10 '14 at 09:11
  • In your question, please? – hd1 Sep 10 '14 at 09:12
  • 1
    and just to mention that it doesn't happen with JDK 1.7 – bhushan Sep 10 '14 at 09:15
  • 1
    As @hd1 requests, edit your question to include new information, especially code that's hard to read in a comment. See also [*How to Install Oracle Java 8 (JDK 8u5) on CentOS/RHEL 6/5 and Fedora*](http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/). – trashgod Sep 10 '14 at 10:35
  • i'm having this issue with eclipse 3.7 on win7x64 (pic is from me) - and yes, the same here, it works perfect with java7 and java6 but java8 (jdk1.8.0_20 and jre1.8.0_20) **DON'T** work... – Martin Frank Oct 15 '14 at 05:15

2 Answers2

1

I had the same issue using JDK 1.8.0_20 and Eclipse 4.4.0. Eclipse kept saying "The import javax.swing.JTable cannot be resolved", and "JTable cannot be resolved to a type". This also wasn't happening in JDK 7 and 6 From my estimation, there must be something wrong with Swing with JDK 8.

To solve the issue, I went to find a .jar file of the Swing package that would contain a working JTable class. After downloading one from http://www.java2s.com/Code/Jar/j/Downloadjavartjarstubs150jar.htm, and incorporating it into my build path, JTable once again worked.

This is not the ideal solution, as the .jar file contains a lot of redundant packages already included in JDK 1.8.0_20, but it was the only solution I could come up, besides downgrading to JDK 7 or 6.

I do hope Oracle does fix this issue soon in future releases of JDK 8.

Hope this helps!

Sorin Markov
  • 59
  • 1
  • 7
1

It seems that there is some compatibility issue with JDK 1.8.0_20 and Eclipse 4.4.0. As it works fine if we refer to JTable in a simple java program written outside Eclipse on the same environment.

After moving to Eclipse 4.5.1 (Eclipse Mars) the problem is resolved.

Hope this is the right solution.

bhushan
  • 46
  • 1
  • 5