Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.sun.awt package usage

Tags:

java

sun

I found a java code and want to use it in my project. It contains these imports that my JDK does not have :

import com.sun.awt.AWTUtilities;
import com.sun.jna.Native;
import com.sun.jna.platform.WindowUtils;

I referred to sun site and found this download page :

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Is it necessary to download all JDK and JRE and replace it from SUN website? My JDK is version 6 and is up to date.

Thank you all

like image 694
sajad Avatar asked Feb 09 '11 04:02

sajad


2 Answers

JNA is an additional library and not part of the standard api, you have to download it (here) and include it in your classpath.

The AWTUtilities class is only distributed with the sun jvm as an implementation detail of the api and as such subject to change, this can break any program depending on it (if possible don't use it).

WindowUtils can be found in the platform.jar, you it can find it on the same page as jna.

like image 84
josefx Avatar answered Sep 30 '22 08:09

josefx


Your JDK should have com.sun.awt.AWTUtilities. It is in rt.jar.

Maybe the problem (for that file) is that your IDE excludes the parent the build path ... on the grounds that it is a bad idea to use those classes directly.

The com.sun.jna classes are not in rt.jar. They apparently may be found in a jna.jar, though I haven't yet found a good place to download it from. (If you use Maven, try this.)

like image 37
Stephen C Avatar answered Sep 30 '22 08:09

Stephen C