1

I have a project that is on github. I have two different computers that use the project. The reason I mention github is because the two computers have the exact same project. But on one of the computers, I get a package does not exist error. That package is com.sun.glass

import com.sun.glass.events.KeyEvent;

Underneath I tried just using

import com.sun.glass

my netbeans autocomplete shows that the package sun exists in com, but the package glass does not exist in sun. I cannot find any info about this error online, and have been searching for days. The strangest part as I said is it works on a different computer.

Both computers are running jdk 1.8. I'm at a loss; Any help would be greatly appreciated.

6
  • 1
    That's why you should not use com.sun.... imports , it's part of a JRE, but there is no assurance that is part of all JRE.
    – minus
    Apr 4, 2017 at 21:34
  • So the issue could be a different JRE on the different computers? I need com.sun.glass.events.KeyEvent; program won't work without it... Apr 4, 2017 at 21:38
  • 1
    Did you perhaps import the wrong class, e.g. did you mean to import java.awt.event.KeyEvent or javafx.scene.input.KeyEvent?
    – Andreas
    Apr 4, 2017 at 21:40
  • That section of code is not mine; I am the sole developer now but this wasn't developed by me. With minor alterations java.awt.event.KeyEvent does work though; Thank you Apr 4, 2017 at 21:41

1 Answer 1

2
import java.awt.event.KeyEvent;

the above is the preferred method of importing the KeyEvent class. There are differences between java KeyEvent and sun KeyEvent, but they are minor. For example:

com.sun.glass.event.KeyEvent.VK_BACKSPACE

is the following in java:

java.awt.event.KeyEvent.VK_BACK_SPACE

So after changing the import from sun to java and making a few changes to its use in the program, it works and is no longer JRE specific.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.