title: Java: Is `sun.awt.image` package deprecated?
body: <p>I was wanting to use some codes that using <code>sun.awt.image.PNGImageDecoder</code> in my project. The problem is source code is based on <strong>Java 8</strong> and my project using <strong>JDK 9+</strong> (11). So I got this error:</p>
  
  <blockquote>
    <p>Package '<code>sun.awt.image</code>' is declared in module '<code>java.desktop</code>', which does not export it to <em>the unnamed module</em>.</p>
  </blockquote>
  
  <p>for <code>import sun.awt.image.*</code>, and: </p>
  
  <blockquote>
    <p>Symbol is declared in module '<code>java.desktop</code>' which does not export package '<code>sun.awt.image</code>'</p>
  </blockquote>
  
  <p>for using <code>PNGImageDecoder</code> or <code>ImageDecoder</code> etc.</p>
  
  <p>After some efforts to find a solution, I found some similar situations that suggest adding <code>requires java.desktop;</code> to <code>module-info.java</code> file (like <a href="https://stackoverflow.com/questions/51503140/the-import-java-awt-cannot-be-resolved">this case</a> and <a href="https://stackoverflow.com/a/42576762/5318303">this case</a>). But as I realized this solution can only be useful when your project already has a <code>module-info.java</code> file and you missing one used module in it. </p>
  
  <p>My project hadn't this file already (pay attention to "<em>the unnamed module</em>" in the first error message). As far as I know, this means all modules are imported automatically. So adding this file and adding that line hadn't any effect except (changing error message and) causing some similar issues for other parts of my codes (which were, of course, solvable by adding required modules to <code>module-info.java</code> file).</p>
  
  <p>To sure I imported all modules in <code>jmods</code> folder (of JDK 11), but the problem didn't solve:</p>
  
  <pre><code>requires java.base;
  requires java.compiler;
  requires java.datatransfer;
  requires java.desktop;
  requires java.instrument;
  requires java.logging;
  requires java.management;
  requires java.management.rmi;
  requires java.naming;
  requires java.net.http;
  requires java.prefs;
  requires java.rmi;
  requires java.scripting;
  requires java.se;
  requires java.security.jgss;
  requires java.security.sasl;
  requires java.smartcardio;
  requires java.sql;
  requires java.sql.rowset;
  requires java.transaction.xa;
  requires java.xml.crypto;
  requires java.xml;
  requires jdk.accessibility;
  requires jdk.aot;
  requires jdk.attach;
  requires jdk.charsets;
  requires jdk.compiler;
  requires jdk.crypto.cryptoki;
  requires jdk.crypto.ec;
  requires jdk.crypto.mscapi;
  requires jdk.dynalink;
  requires jdk.editpad;
  requires jdk.hotspot.agent;
  requires jdk.httpserver;
  requires jdk.internal.ed;
  requires jdk.internal.jvmstat;
  requires jdk.internal.le;
  requires jdk.internal.opt;
  requires jdk.internal.vm.ci;
  requires jdk.internal.vm.compiler;
  requires jdk.internal.vm.compiler.management;
  requires jdk.jartool;
  requires jdk.javadoc;
  requires jdk.jcmd;
  requires jdk.jconsole;
  requires jdk.jdeps;
  requires jdk.jdi;
  requires jdk.jdwp.agent;
  requires jdk.jfr;
  requires jdk.jlink;
  requires jdk.jshell;
  requires jdk.jsobject;
  requires jdk.jstatd;
  requires jdk.localedata;
  requires jdk.management.agent;
  requires jdk.management.jfr;
  requires jdk.management;
  requires jdk.naming.dns;
  requires jdk.naming.rmi;
  requires jdk.net;
  requires jdk.pack;
  requires jdk.rmic;
  requires jdk.scripting.nashorn;
  requires jdk.scripting.nashorn.shell;
  requires jdk.sctp;
  requires jdk.security.auth;
  requires jdk.security.jgss;
  requires jdk.unsupported.desktop;
  requires jdk.unsupported;
  requires jdk.xml.dom;
  requires jdk.zipfs;
  </code></pre>
  
  <hr>
  
  <p>I know this package (<code>sun.awt.image</code>) exists in <code>java.desktop</code> module (of JDK 11), but don't know how can access it. </p>
  
  <p>I use IntelliJ IDEA as IDE.</p>