당신은 주제를 찾고 있습니까 “package com sun image codec jpeg does not exist – Error “package android.support.v7.app does not exist”“? 다음 카테고리의 웹사이트 https://chewathai27.com/you 에서 귀하의 모든 질문에 답변해 드립니다: https://chewathai27.com/you/blog. 바로 아래에서 답을 찾을 수 있습니다. 작성자 java tmz 이(가) 작성한 기사에는 조회수 7,530회 및 좋아요 54개 개의 좋아요가 있습니다.
package com sun image codec jpeg does not exist 주제에 대한 동영상 보기
여기에서 이 주제에 대한 비디오를 시청하십시오. 주의 깊게 살펴보고 읽고 있는 내용에 대한 피드백을 제공하세요!
d여기에서 Error “package android.support.v7.app does not exist” – package com sun image codec jpeg does not exist 주제에 대한 세부정보를 참조하세요
Error “package android.support.v7.app does not exist”
———————————————————————-
First of all check if your project is using androidx or android support library. Check gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
If it contains the above lines, it is using androidx with an old code from some old tutorial.
In build.gradle (module:app)
Use
implementation ‘androidx.appcompat:appcompat:1.0.0’
Instead of
compile ‘com.android.support:appcompat-v7:28.0.0’
Also in MainActivity.java : Use
import androidx.appcompat.app.AppCompatActivity;
instead of :
import android.support.v7.app.AppCompatActivity;
package com sun image codec jpeg does not exist 주제에 대한 자세한 내용은 여기를 참조하세요.
import com.sun.image.codec.jpeg. – java – Stack Overflow
I had this problem when compiling with JDK 7. Strange enough Eclipse d not show this error, only javac d. The answer can be found in this Stackoverflow …
Source: stackoverflow.com
Date Published: 2/11/2021
View: 6315
Package com.sun.image.codec.jpeg does not exist – Katastros
Reason: Image processing JPEGCodec has been removed from Jdk1.7. Solution 1: This problem can be solved by configuring the maven-compiler-plugin plug-in.
Source: blog.katastros.com
Date Published: 8/12/2022
View: 9598
Package com.sun.image.codec.jpeg does not exist – Birost
Some old Java code compiled under JDK1.7 will report errors, such as This: The package com.sun.image.codec.jpeg does not exist.
Source: blog.birost.com
Date Published: 6/9/2022
View: 8707
[JDK 7] package com.sun.image.codec.jpeg does not exist
Reproducible in a plain Java SE project by adding e.g. import com.sun.image.codec.jpeg.JPEGCodec; to any source, but only when building on JDK 7 …
Source: bz.apache.org
Date Published: 3/1/2022
View: 2833
package com.sun.image.codec.jpeg does not exist #12 – GitHub
When javac is compiling code it doesn’t link against rt.jar by default. Instead it uses special symbol file lib/ct.sym with stubs.
Source: github.com
Date Published: 4/11/2021
View: 500
Gradle build package com sun. image. codec. JPEG does not …
JPEG does not exist, solution. Gradle build package com sun. image. codec. JPEG does not exist, solution. 2022-04-21 06:46:12 【Mingyueyixi】 …
Source: chowdera.com
Date Published: 9/7/2022
View: 7710
com.sun.image.codec.jpeg does not exist | 云里雾里
问题描述一个项目在windows下执行mvn package正常,但是放在Linux环境下,会出现找不到com.sun.image.codec的问题, …
Source: damonyi.cc
Date Published: 5/10/2021
View: 8231
import com.sun.image.codec.jpeg.* – 程序员的小窝
MyClass.java:33: package com.sun.image.codec.jpeg does not exist [javac] import com.sun.image.codec.jpeg.*; [javac] ^. what can I do ?
Source: www.javawenti.com
Date Published: 2/13/2022
View: 542
Retire the non-standard package com.sun.image.codec.jpeg
The package com.sun.image.codec.jpeg was added in JDK 1.2 (Dec 1998) … I can’t speak for others – and probably only direct Sun licensees
Source: bugs.openjdk.org
Date Published: 12/18/2021
View: 4205
[Maven]package com.sun.image.codec.jpeg does not exist
Why are you using es in the package com.sun.image.codec.jpeg? You are not supposed to use those es directly: Why Developers Should …
Source: www.796t.com
Date Published: 1/29/2022
View: 3850
주제와 관련된 이미지 package com sun image codec jpeg does not exist
주제와 관련된 더 많은 사진을 참조하십시오 Error “package android.support.v7.app does not exist”. 댓글에서 더 많은 관련 이미지를 보거나 필요한 경우 더 많은 관련 기사를 볼 수 있습니다.
주제에 대한 기사 평가 package com sun image codec jpeg does not exist
- Author: java tmz
- Views: 조회수 7,530회
- Likes: 좋아요 54개
- Date Published: 2021. 1. 19.
- Video Url link: https://www.youtube.com/watch?v=EjWrfnN7H_Y
import com.sun.image.codec.jpeg.*
I have a Java program when I compile it I get the following error
[javac] …\MyClass.java:33: package com.sun.image.codec.jpeg does not exist [javac] import com.sun.image.codec.jpeg.*; [javac] ^what can I do ?
What is the correct way of writing an image file now that the com.sun package is deprecated.
Package com.sun.image.codec.jpeg does not exist
Reason: Image processing JPEGCodec class has been removed from Jdk1.7.
Solution 1: This problem can be solved by configuring the maven-compiler-plugin plug-in.
Add this configuration to the plugin
maven-compiler-plugin
2.5.1
1.7
UTF-8
${java.home}\lib\rt.jar;${java.home}\lib\jce.jar Solution 2: Code changes
Possible problem code:
import java.awt.image.BufferedImage; //import com.sun.image.codec.jpeg.JPEGCodec; //import com.sun.image.codec.jpeg.JPEGImageEncoder; import javax.imageio.ImageIO;
After modification:
Package com.sun.image.codec.jpeg does not exist
FileOutputStream out = new FileOutputStream(dstName);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(dstImage);
String formatName = dstName.substring(dstName.lastIndexOf(“.”) + 1);
//FileOutputStream out = new FileOutputStream(dstName);
//JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
//encoder.encode(dstImage) ;
ImageIO.write(dstImage,/*”GIF”*/formatName/* format desired */, new File(dstName)/* target */);
import java.awt.image.BufferedImage;
//import com.sun.image.codec.jpeg.JPEGCodec;
//import com.sun.image.codec.jpeg.JPEGImageEncoder;
import javax.imageio.ImageIO;
static void saveImage(BufferedImage dstImage, String dstName) throws IOException { String formatName = dstName.substring(dstName.lastIndexOf(“.”) + 1); //FileOutputStream out = new FileOutputStream(dstName); //JPEGImageEncoder encoder = JPEGCodec. createJPEGEncoder(out); //encoder.encode(dstImage); ImageIO.write(dstImage,/*”GIF”*/formatName/* format desired */, new File(dstName)/* target */); }
Retrieved from[url]http://www.vktone.com/articles/com-sun-image-codec-jpeg-not-found.html[/url]Some old Java code compiled under JDK1.7 will report errors, such as This: The package com.sun.image.codec.jpeg does not exist.[javac] D:\work\mpa\hyjc2\src\hyjc\image\ImageUtil.java:87: Error: Cannot find symbol[javac] JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);[javac] ^[javac] Symbol: Class JPEGImageEncoderbecause this JPEGImageEncoder is a private implementation of sun company.Generally appear in such a Java code segment:Should be changed to this Java code:This is no problem, because the unified ImageIO is used to read and write image format files, and there is no need to use the outdated implementation class JPEGImageEncoder class.Because many articles on the Internet talk about this issue [the package com.sun.image.codec.jpeg does not exist], they all talk about the issue of rt.jar, and they didn’t mention the idea, so I published it specifically, hope that Everyone is helpful.Note that the following classes are used when processing image formats in general.Written as a method://2013.05.04
206774 – [JDK 7] package com.sun.image.codec.jpeg does not exist
This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project’s instructions for reporting issues.
package com.sun.image.codec.jpeg does not exist · Issue #12 · aiinspur/blog
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Pick a username Email Address Password Sign up for GitHub
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradle build package com sun. image. codec. JPEG does not exist, solution
Gradle Build error : Package com.sun.image.codec.jpeg non-existent
D:\Projects\EclipseProjects\JavaDog\sample\y2018\date0912\ Bulk download \DpiUtil.java:12: error : Package com.sun.image.codec.jpeg non-existent import com.sun.image.codec.jpeg.JPEGCodec;
reason
This is because classpath Contains no sun Some of the company’s packages lead to .
jdk1.7 Start jdk Sold to oracle,sun Some of the company’s packages are not included in jdk in , Become private , The default is not to use , So the compilation failed .
What is it for? ,eclipse、IDEA Be able to compile through , And use it alone gradle perhaps maven no way ?
eclipse and IDEA stay run When , Default classpath Add a lot of jar package . for example IDEA Run a main Method , Combined with the -classpath Parameters :
“C:\Program Files\Java\jdk1.8.0_202\bin\java.exe” -javaagent:D:\Programming\IDE\IdeaIU\lib\idea_rt.jar = 57164:D:\Programming\IDE\IdeaIU\bin -Dfile.encoding = UTF-8 -classpath “C:\Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\deploy.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\access-bridge-64.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\cldrdata.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\dnsns.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jaccess.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jfxrt.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\localedata.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext
ashorn.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunec.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunjce_provider.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunmscapi.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunpkcs11.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\zipfs.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\javaws.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfr.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfxswt.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\jsse.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\management-agent.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\plugin.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar; C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar; D:\Projects\EclipseProjects\JavaDog\out\production\classes; D:\Projects\EclipseProjects\JavaDog\libs\core-3.2.2-SNAPSHOT.jar; D:\Projects\EclipseProjects\JavaDog\libs\httpclient-4.5.2.jar; D:\Projects\EclipseProjects\JavaDog\libs\xmlpull_1_1_3_4c.jar; D:\Projects\EclipseProjects\JavaDog\libs\cpdetector\ext\jargs-1.0.jar; D:\Projects\EclipseProjects\JavaDog\libs\cpdetector\ext\antlr-2.7.4.jar; D:\Projects\EclipseProjects\JavaDog\libs\retrofit-2.5.0.jar; D:\Projects\EclipseProjects\JavaDog\libs\okio-1.11.0.jar; D:\Projects\EclipseProjects\JavaDog\libs\cpdetector\ext\chardet-1.0.jar; D:\Projects\EclipseProjects\JavaDog\libs\fastjson-1.2.9.jar; D:\Projects\EclipseProjects\JavaDog\libs\reactive-streams-1.0.2.jar; D:\Projects\EclipseProjects\JavaDog\libs\mariadb-java-client-2.1.2.jar; D:\Projects\EclipseProjects\JavaDog\libs\javase-3.2.1.jar; D:\Projects\EclipseProjects\JavaDog\libs\rxjava-2.2.3.jar; D:\Projects\EclipseProjects\JavaDog\libs\javax.mail.jar; D:\Projects\EclipseProjects\JavaDog\libs\dom4j-1.6.1.jar; D:\Projects\EclipseProjects\JavaDog\libs\okhttp-3.5.0.jar; D:\Projects\EclipseProjects\JavaDog\libs\javase-3.2.1-sources.jar; D:\Projects\EclipseProjects\JavaDog\libs\mysql-connector-java-5.0.5-bin.jar; D:\Projects\EclipseProjects\JavaDog\libs\kxml2-2.2.2.jar; D:\Projects\EclipseProjects\JavaDog\libs\jsoup-1.11.3.jar; D:\Projects\EclipseProjects\JavaDog\libs\cpdetector\cpdetector_1.0.10.jar; C:\Users\Lu\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.5.2\junit-jupiter-api-5.5.2.jar; C:\Users\Lu\.m2\repository\org\junit\platform\junit-platform-commons\1.5.2\junit-platform-commons-1.5.2.jar; C:\Users\Lu\.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar; C:\Users\Lu\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar” y2018.date0912. Bulk download .Test
resolvent
1、 Will report an error sun Package code removal , Use other api Instead of .( recommend *****)
2、 take jre/lib/rt.jar Join in classpath in ( recommend ***)
3、 take jre/lib/rt.jar Join the rely on ( recommend **)
Join in classpath It’s a solution , But there is no guarantee that different environments can be implemented steadily , For example, special new jdk Or some custom jdk. Add dependency Library , For example, the of the project libs Directory , Also do not recommend , Packing will increase the volume .
Recommended replacement , Maintain program compatibility 、 reliability .
PS:
1、sun There are many different types of bags , It needs to be replaced in different ways , No discussion .
2、 The following build scripts are kotlin Script , namely build.gradle.kts ,xxx.gradle Basically applicable , But it needs a little modification .
3、 The following code does not add classpath But join bootstrapClasspath , This is because classpath It’s actually read-only ,
4、 The old version gradle May need to use classbootpath, The new version uses bootstrapClasspath
This article currently uses gradle by 6.1 edition . The latest official version .
Reference resources :
https://docs.gradle.org/current/userguide/upgrading_version_4.html#potential_breaking_changes
The CompileOptions.bootClasspath property has been removed — use CompileOptions.bootstrapClasspath instead.
take jre/lib/rt.jar Join the rely on ( recommend ***)
It’s simple , To jdk/jre/lib/ Copy rt.jar Join in libs directory .
Can’t copy to libs, Direct configuration jdk/jre/lib/rt.jar Path to dependency is invalid , It should be ok , But not actually , Unknown cause .
var JAVA_HOME = System . getenv ( “JAVA_HOME” ) dependencies { implementation ( fileTree ( ” $JAVA_HOME $/jre/lib/rt.jar” ) ) }
Actually, just configure this
implementation ( fileTree ( mapOf ( “dir” to “libs” , “include” to listOf ( “*.jar” ) ) ) )
take jre/lib/rt.jar Join in classpath in ( recommend **)
A simple way of writing
var JAVA_HOME = System . getenv ( “JAVA_HOME” ) tasks . withType ( JavaCompile :: class ) { options . bootstrapClasspath = fileTree ( ” $JAVA_HOME /jre/lib/rt.jar” ) }
reference IDEA How to write a construction
More perfect , Add a pile of jar package
com.sun.image.codec.jpeg does not exist
问题描述
一个项目在windows下执行mvn package正常,但是放在Linux环境下,会出现找不到com.sun.image.codec的问题,如下所示
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[ERROR] COMPILATION ERROR : [INFO] ————————————————————- [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController2.java:[24,40] package com.sun.image.codec.jpeg does not exist [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController2.java:[25,40] package com.sun.image.codec.jpeg does not exist [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController.java:[25,32] package com.sun.image.codec.jpeg does not exist [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController.java:[26,32] package com.sun.image.codec.jpeg does not exist [INFO] 4 errors [INFO] ————————————————————- [INFO] ———————————————————————— [INFO] Reactor Summary: [INFO] [INFO] ztzx 1.0.0 ………………………………….. SUCCESS [ 0.007 s] [INFO] ztzx.service ………………………………… FAILURE [02:11 min] [INFO] ztzx.web 1.0.0 ………………………………. SKIPPED [INFO] ———————————————————————— [INFO] BUILD FAILURE [INFO] ———————————————————————— [INFO] Total time: 02:11 min [INFO] Finished at: 2018-08-06T01:51:45Z [INFO] ———————————————————————— [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ztzx.service: Compilation failure: Compilation failure: [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController2.java:[24,40] package com.sun.image.codec.jpeg does not exist [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController2.java:[25,40] package com.sun.image.codec.jpeg does not exist [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController.java:[25,32] package com.sun.image.codec.jpeg does not exist [ERROR] /home/ztzx/ztzx.service/src/main/java/com/telchina/ztzx/common/controller/UploadController.java:[26,32] package com.sun.image.codec.jpeg does not exist [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn-rf :ztzx.service 分析一
按照Java官方的解释,sun.image.codec这个package已经被deprecated,建议不要使用,看官方的解释: Why Developers Should Not Write Programs That Call ‘sun’ Packages The java.*, javax.* and org.* packages documented in the Java Platform Standard Edition API Specification make up the official, supported, public interface. If a Java program directly calls only API in these packages, it will operate on all Java-compatible platforms, regardless of the underlying OS platform. The sun.* packages are not part of the supported, public interface. A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform. Each company that implements the Java platform will do so in their own private way. The classes in sun.* are present in the JDK to support Oracle’s implementation of the Java platform: the sun.* classes are what make the Java platform classes work “under the covers” for Oracle’s JDK. These classes will not in general be present on another vendor’s Java platform. If your Java program asks for a class “sun.package.Foo” by name, it may fail with ClassNotFoundError, and you will have lost a major advantage of developing in Java. Technically, nothing prevents your program from calling into sun.* by name. From one release to another, these classes may be removed, or they may be moved from one package to another, and it’s fairly likely that their interface (method names and signatures) will change. (From Oracle’s point of view, since we are committed to maintaining the Java platform, we need to be able to change sun.* to refine and enhance the platform.) In this case, even if you are willing to run only on Oracle’s implementation, you run the risk of a new version of the implementation breaking your program. In general, writing java programs that rely on sun.* is risky: those classes are not portable, and are not supported
可以这样理解,Java已经被Oracle收购多年,里面再去出现sun的package算怎么回事。。O(∩_∩)O哈哈~,当然你还是可以去使用的,可以在pom.xml 经配置了下面的参数,排除无法引入jar包的问题,这个方法并不能解决我在Linux无法进行构建的的问题。
1
2
3
4
5
6
7
8
9
10
11
12
13
org.apache.maven.plugins
maven-compiler-plugin
3.1
${jdkVersion}
${JAVA_HOME}/jre/lib/rt.jar${path.separator}${JAVA_HOME}/jre/lib/jce.jar 分析二
查看mvn仓库信息
1
2
3
4
5
6
7
8
root@30e8e1cd5962:/home/ztzx# mvn -version
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T19:49:05Z)
Maven home: /usr/share/maven
Java version: 1.8.0_91, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: “linux”, version: “3.10.0-693.el7.x86_64”, arch: “amd64”, family: “unix”
“`查看Java 信息
root@30e8e1cd5962:/home/ztzx# java -version
openjdk version “1.8.0_91”
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-1~bpo8+1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
1
2
3
4
5
与windows的运行环境相比,出Java的小版本不同外,还有一个区别,就是Oracle Java与OpenJdk的区别,google资料,发现OpenJdk已经在1.7版本移除了该package。[OpenJdk移除jepg的package](http://jira.icesoft.org/browse/PDF-332?jql=project%20%3D%20PDF%20AND%20fixVersion%20%3D%205.1%20ORDER%20BY%20updated%20DESC%2C%20priority%20DESC%2C%20created%20ASC),将Linux 默认的OpenJdk替换为Oracle的Jdk,即可以解决问题
### 其他解决方法
JPEGImageEncoder类是SUN公司私有类
一般出现在这样的代码段中:
FileOutputStream out = new FileOutputStream(dstName);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(dstImage);
改写成:
String formatName = dstName.substring(dstName.lastIndexOf(“.”) + 1); //FileOutputStream out = new FileOutputStream(dstName); //JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); //encoder.encode(dstImage); ImageIO.write(dstImage, /*”GIF”*/ formatName /* format desired */ , new File(dstName) /* target */ );
“`
都使用统一的ImageIO进行图像格式文件的读写,没有必要使用过时的实现类JPEGImageEncoder类。
import com.sun.image.codec.jpeg.*
import com.sun.image.codec.jpeg.*
I have a Java program when I compile it I get the following error [javac] …\MyClass.java:33: package com.sun.image.codec.jpeg does not exist [javac] import com.sun.image.codec.jpeg.*; [javac] ^ what can I do ? What is the correct way of writing an image file now that the com.sun package is deprecated.
Why are you using classes in the package com.sun.image.codec.jpeg ? You are not supposed to use those classes directly: Why Developers Should Not Write Programs That Call ‘sun’ Packages. What does your program do? Does it just try to read or write a JPG image? That’s very easy with the ImageIO API. See this tutorial: Writing/Saving an Image. Addition – The package com.sun.image.codec.jpeg has been removed in Java 7 as mentioned in the Java SE 7 and JDK 7 Compatibility Guide. Synopsis: The Non-standard com.sun.image.codec.jpeg Package is Retired Description: The com.sun.image.codec.jpeg package was added in JDK 1.2 (Dec 1998) as a non-standard way of controlling the loading and saving of JPEG format image files. This package was never part of the platform specification and it has been removed from the Java SE 7 release. The Java Image I/O API was added to the JDK 1.4 release as a standard API and eliminated the need for the com.sun.image.codec.jpeg package.
I had this problem when compiling with JDK 7. Strange enough Eclipse did not show this error, only javac did. The answer can be found in this Stackoverflow answer: javac uses a special symbol table that does not include all Sun-proprietary classes, and suppliying -XDignore.symbol.file makes the problem go away. Of course, a much better solution is to rewrite the code without using the proprietary classes, but to support JDK 7 quickly, this option works.
采集自互联网,如有侵权请联系本人
[JDK-6527962] Retire the non-standard package com.sun.image.codec.jpeg
The package com.sun.image.codec.jpeg was added in JDK 1.2 (Dec 1998)as a non-standard way of controlling the loading and saving of JPEGformat image files.It has never been part of the platform specification and is not partof any compatibility test suite and so compatible Java implementationsare not required to include it.The documentation for it has always been buried under a separate’other API’ heading, clearly distinct from the Java platform APIspecification. The intention was to replace it with a standard API.In JDK 1.4 (FCS/GA 2001) the Java Image I/O API was added(see JSR-15 at http://jcp.org/en/jsr/detail?id=15) as a standard API.This resides in the package javax.imageio.It provides a standard mechanism for controlling the loading andsaving of sampled image formats and requires all compliant Java SEimplementations to support JPEG as per the Image I/O specification.In JDK 6 to encourage migration to Image I/O several things happened.1. All documentation of com.sun.image.codec.jpeg was removedalthough the classes are still present in *Sun* implementations- I can’t speak for others – and probably only direct Sun licenseesare likely to ship the API assuming they bother to do so.2. When compiling code using these classes using JDK 6 a warningis emitted :warning: com.sun.image.codec.jpeg.JPEGCodec is Sun proprietary API andmay be removed in a future releaseJPEGCodec.createJPEGDecoder(…);3. There were substantial performance improvements to Image I/Oincluding JPEG, and overall the performance is now very similarbetween the two APIs.So we think its time to retire com.sun.image.codec.jpeg so wecan focus on the single preferred standard API.However we are aware that applications do still use it, typicallybecause they were written to run on JDK versions prior to 1.4,There are several options, not all exclusive :1. Remove completely in JDK 7 – the most aggressive option.2. Warn in JDK 7 release notes that it will be removed completely inJDK8 – this is really just incremental to the existing compilationwarning3. Make further javac changes in JDK 7 so that the classes are notlocated when compiling. ie the compilation warning turns into an error.Again, with this option the classes *are* still available at runtime sothat code compiled with 1.6 or earlier will still find these classesand run on JDK 7 This preserves binary compatibility.4. Remove the classes completely in a release after JDK 7after a combination of notifications via release notesand compiler warnings/errors. Ideally this would thenhappen in JDK8Implementing 2+3+4 comes down to using JDK 7 to providea further period of grace to migrate and probably providesthe right balance between notice and compatibility (to thesenon-standard, unsupported APIs). Particularly since JDK 6already began this process.How long does this give people to migrate?Our historical run rate of releases is one every two years.JDK 1.2 – Dec 1998…JDK 6 Nov 2006Management may try different models and so forth but I thinkthat’s a good enough estimate which predictsJDK7 – late 2008JDK8 – late 2010
[Maven]package com.sun.image.codec.jpeg does not exist
sym 接下來 workspace lock nis program uic edit 問題
—————————————————————–
原創博文,如需轉載請註明出處!
博主:疲憊的豆豆
鏈接:http://www.cnblogs.com/dzblog/p/6971245.html
—————————————————————-
環境
Maven:3.0.5
Java:1.8.0_45
OS:Linux
問題
拿到一個java項目,想編譯一下,報了如下錯誤:
[INFO] ————————————————————- [ERROR] COMPILATION ERROR : [INFO] ————————————————————- [ERROR] /var/lib/jenkins/jobs/sample_xxx_pipeline/workspace/src/test/java/com/xxx/sxxxx/ib/pdf/PdfServiceTest.java:[ 6 , 31 ] error: package com.sun.image.codec.jpeg does not exist [ERROR] /var/lib/jenkins/jobs/sample_xxx_pipeline/workspace/src/test/java/com/xxx/sxxxx/ib/pdf/PdfServiceTest.java:[ 7 , 31 ] error: package com.sun.image.codec.jpeg does not exist [INFO] 2 errors [INFO] ————————————————————- [INFO] ———————————————————————— [INFO] BUILD FAILURE [INFO] ———————————————————————— [INFO] Total time : 12 .361s [INFO] Finished at: Thu Jun 08 19 : 16 : 04 CST 2017 [INFO] Final Memory: 75M / 1614M [INFO] ————————————————————————出錯原因(來自stack overflow):
Why are you using classes in the package com.sun.image.codec.jpeg? You are not supposed to use those classes directly: Why Developers Should Not Write Programs That Call ‘sun‘ Packages.
What does your program do? Does it just try to read or write a JPG image? That‘s very easy with the ImageIO API. See this tutorial: Writing/Saving an Image.
Addition – The package com.sun.image.codec.jpeg has been removed in Java 7 as mentioned in the Java SE 7 and JDK 7 Compatibility Guide.
Synopsis: The Non-standard com.sun.image.codec.jpeg Package is Retired
Description: The com.sun.image.codec.jpeg package was added in JDK 1.2 (Dec 1998) as a non-standard way of controlling the loading and saving of JPEG format image files. This package was never part of the platform specification and it has been removed from the Java SE 7 release. The Java Image I/O API was added to the JDK 1.4 release as a standard API and eliminated the need for the com.sun.image.codec.jpeg package.
大意就是JDK7的時候,這個類已經退休了,以後凡是帶sun.*的類庫將不會被支持,畢竟sun已經被收購多年了,還sun,sun的,oracle看著心裏多難受,全部給搞掉。請看官方說明。
貼心的粘過來:
Why Developers Should Not Write Programs
That Call ‘sun‘ Packages
The java.*, javax.* and org.* packages documented in the Java Platform Standard Edition API Specification make up the official, supported, public interface.
If a Java program directly calls only API in these packages, it will operate on all Java-compatible platforms, regardless of the underlying OS platform.
The sun.* packages are not part of the supported, public interface.
A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.
Each company that implements the Java platform will do so in their own private way. The classes in sun.* are present in the JDK to support Oracle‘s implementation of the Java platform: the sun.* classes are what make the Java platform classes work “under the covers” for Oracle‘s JDK. These classes will not in general be present on another vendor‘s Java platform. If your Java program asks for a class “sun.package.Foo” by name, it may fail with ClassNotFoundError, and you will have lost a major advantage of developing in Java.
Technically, nothing prevents your program from calling into sun.* by name. From one release to another, these classes may be removed, or they may be moved from one package to another, and it‘s fairly likely that their interface (method names and signatures) will change. (From Oracle‘s point of view, since we are committed to maintaining the Java platform, we need to be able to change sun.* to refine and enhance the platform.) In this case, even if you are willing to run only on Oracle‘s implementation, you run the risk of a new version of the implementation breaking your program.
In general, writing java programs that rely on sun.* is risky: those classes are not portable, and are not supported.
解決問題
當然最好的辦法是,按照oracle(我下意識寫成了sun)的要求,使用新的API,不過推動項目owner來改,確實麻煩,畢竟我只是想編譯一下看看。
網上失敗的解決辦法:
這個方法在我這裏失敗,修改pom.xml文件如下:可能有成功的小夥伴吧,要不往上也不會到處都是這個解決辦法的轉載。
< plugin > < groupId > org.apache.maven.plugins groupId > < artifactId > maven-compiler-plugin artifactId > < version > 3.1 version > < configuration > < source > 1.8 source > < target > 1.8 target > < compilerArguments > < bootclasspath > ${java.home}/lib/rt.jar;${java.home}/lib/jce.jar bootclasspath > compilerArguments > configuration > plugin >
很遺憾,在我這裏報錯,出錯是Unable to find package java.lang in classpath or bootclasspath。
如果使用這種方案修改的,請確保你的${java.home}可用,或者使用mvn help:system命令查看所有環境變量,進行更改。
stack overflow有同病相憐者,地址。
成功的解決方法:
I had this problem when compiling with JDK 7. Strange enough Eclipse did not show this error, only javac did. The answer can be found in this Stackoverflow answer: javac uses a special symbol table that does not include all Sun-proprietary classes, and suppliying -XDignore.symbol.file makes the problem go away.
Of course, a much better solution is to rewrite the code without using the proprietary classes, but to support JDK 7 quickly, this option works.
首先我的pom.xml文件是這樣的:
< plugin > < groupId > org.apache.maven.plugins groupId > < artifactId > maven-compiler-plugin artifactId > < version > 2.5 version > < configuration > < source > 1.8 source > < target > 1.8 target > configuration > plugin >
接下來,只需要添加一句話既可解決:
< plugin > < groupId > org.apache.maven.plugins groupId > < artifactId > maven-compiler-plugin artifactId > < version > 2.5 version > < configuration > < source > 1.8 source > < target > 1.8 target > < compilerArgument > -XDignore.symbol.file compilerArgument > configuration > plugin >
再次編譯,成功~~撒花~~~
END
[Maven]package com.sun.image.codec.jpeg does not exist
키워드에 대한 정보 package com sun image codec jpeg does not exist
다음은 Bing에서 package com sun image codec jpeg does not exist 주제에 대한 검색 결과입니다. 필요한 경우 더 읽을 수 있습니다.
이 기사는 인터넷의 다양한 출처에서 편집되었습니다. 이 기사가 유용했기를 바랍니다. 이 기사가 유용하다고 생각되면 공유하십시오. 매우 감사합니다!
사람들이 주제에 대해 자주 검색하는 키워드 Error “package android.support.v7.app does not exist”
- 동영상
- 공유
- 카메라폰
- 동영상폰
- 무료
- 올리기
Error #“package #android.support.v7.app #does #not #exist”
YouTube에서 package com sun image codec jpeg does not exist 주제의 다른 동영상 보기
주제에 대한 기사를 시청해 주셔서 감사합니다 Error “package android.support.v7.app does not exist” | package com sun image codec jpeg does not exist, 이 기사가 유용하다고 생각되면 공유하십시오, 매우 감사합니다.