pink_violet
2021-05-21 14:01
采纳率: 100%
浏览 333
已采纳

idea运行java代码出现一堆错误是为什么?

 

  • import com.sun.image.codec.jpeg.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    import java.awt.*;
    import java.io.*;
    class PaintCanvas extends Canvas {
       BufferedImage image;
       Graphics2D g_2d;
       PaintCanvas() {
          image=new BufferedImage(300,300,BufferedImage.TYPE_INT_RGB);
          g_2d=image.createGraphics();
          Rectangle2D rect = new Rectangle2D.Double(0,0,300,300);
          Ellipse2D ellipse= new Ellipse2D. Double (30,30,80,30);
          g_2d.setColor(Color.yellow);
          g_2d.fill(rect); 
          g_2d.setColor(Color.black);
          AffineTransform trans=new  AffineTransform(); 
          for(int i=1;i<=24;i++){
             trans.rotate(15.0*Math.PI/180,70,45);
             g_2d.setTransform(trans);
             g_2d.draw(ellipse); 
          }
       }
       public BufferedImage getImage() {
          return image;
       }
    }
    public class JPG {
      public static void main(String args[]) {
        try {  
           JPEGImageEncoder encoder=
           JPEGCodec.createJPEGEncoder(new FileOutputStream("geometry.jpg"));
           PaintCanvas canvas=new PaintCanvas(); 
           encoder.encode(canvas.getImage());
        }
        catch(Exception ee) {}
      }
    }

 

 

  • Error:Internal error: (java.lang.NoClassDefFoundError) Could not initialize class com.intellij.util.io.FileChannelUtil
    java.lang.NoClassDefFoundError: Could not initialize class com.intellij.util.io.FileChannelUtil
    	at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext$1.execute(ReadWriteDirectBufferWrapper.java:50)
    	at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext$1.execute(ReadWriteDirectBufferWrapper.java:42)
    	at com.intellij.openapi.util.io.FileUtilRt.doIOOperation(FileUtilRt.java:945)
    	at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext.<init>(ReadWriteDirectBufferWrapper.java:42)
    	at com.intellij.util.io.ReadWriteDirectBufferWrapper.create(ReadWriteDirectBufferWrapper.java:27)
    	at com.intellij.util.io.DirectBufferWrapper.getBuffer(DirectBufferWrapper.java:24)
    	at com.intellij.util.io.ReadWriteDirectBufferWrapper.getBuffer(ReadWriteDirectBufferWrapper.java:16)
    	at com.intellij.util.io.PagedFileStorage$StorageLock.createValue(PagedFileStorage.java:631)
    	at com.intellij.util.io.PagedFileStorage$StorageLock.get(PagedFileStorage.java:558)
    	at com.intellij.util.io.PagedFileStorage$StorageLock.access$500(PagedFileStorage.java:466)
    	at com.intellij.util.io.PagedFileStorage.getBufferWrapper(PagedFileStorage.java:407)
    	at com.intellij.util.io.PagedFileStorage.getBuffer(PagedFileStorage.java:371)
    	at com.intellij.util.io.PagedFileStorage.putInt(PagedFileStorage.java:144)
    	at com.intellij.util.io.ResizeableMappedFile.putInt(ResizeableMappedFile.java:222)
    	at com.intellij.util.io.PersistentEnumeratorBase.markDirty(PersistentEnumeratorBase.java:597)
    	at com.intellij.util.io.PersistentEnumeratorBase.<init>(PersistentEnumeratorBase.java:185)
    	at com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:73)
    	at com.intellij.util.io.PersistentEnumeratorDelegate.<init>(PersistentEnumeratorDelegate.java:47)
    	at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:149)
    	at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:138)
    	at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:129)
    	at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:121)
    	at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:114)
    	at org.jetbrains.jps.incremental.storage.AbstractStateStorage.createMap(AbstractStateStorage.java:124)
    	at org.jetbrains.jps.incremental.storage.AbstractStateStorage.<init>(AbstractStateStorage.java:27)
    	at org.jetbrains.jps.incremental.storage.FileTimestampStorage.<init>(FileTimestampStorage.java:27)
    	at org.jetbrains.jps.incremental.storage.ProjectStamps.<init>(ProjectStamps.java:39)
    	at org.jetbrains.jps.incremental.storage.ProjectTimestamps.<init>(ProjectTimestamps.java:19)
    	at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:92)
    	at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:274)
    	at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:130)
    	at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:232)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    	at java.base/java.lang.Thread.run(Thread.java:831)
    

 

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • CSDN专家-sinjack 2021-05-21 14:02
    已采纳

    Could not initialize class com.intellij.util.io.FileChannelUtil不能实例化

    点赞 打赏 评论
  • 有问必答小助手 2021-05-25 14:43

    您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

    点赞 打赏 评论
  • 陈皮的JavaLib 2021-08-03 16:58

    设置项目的JDK版本到你项目正确的版本,因为有些IDEA默认会设置为1.6版本。

    点赞 打赏 评论

相关推荐 更多相似问题