当前位置: 首页 > news >正文

Java:openjdk: error: Student is abstract; cannot be instantiated;java编译环境

文章目录

编译环境

jdk

需要安装的javac 在java-devel 包里
[root@10 ~]# rpm -qf /usr/bin/javac
file /usr/bin/javac is not owned by any package
[root@10 ~]# ll /usr/bin/javac
lrwxrwxrwx. 1 root root 23 Jun 15 09:52 /usr/bin/javac -> /etc/alternatives/javac
[root@10 ~]# ll /etc/alternatives/javac
lrwxrwxrwx. 1 root root 32 Jun 15 16:51 /etc/alternatives/javac -> /usr/java/jdk-18.0.1.1/bin/javac
[root@10 ~]# rpm -qf /usr/java/jdk-18.0.1.1/bin/javac
jdk-18-18.0.1.1-ga.x86_64
[root@10 ~]# rpm -qi jdk-18-18.0.1.1-ga.x86_64
Name : jdk-18
Epoch : 2000
Version : 18.0.1.1
Release : ga
Architecture: x86_64
Install Date: Wed 15 Jun 2022 04:51:53 PM EDT
Group : Development/Tools
Size : 318287114
License : https://java.com/freeuselicense
Signature : RSA/SHA256, Mon 25 Apr 2022 04:56:36 PM EDT, Key ID 72f97b74ec551f03
Source RPM : jdk-18-18.0.1.1-ga.src.rpm
Build Date : Mon 25 Apr 2022 04:55:52 PM EDT
Build Host : java.com
Relocations : /usr/java
Vendor : Oracle Corporation
URL : http://www.oracle.com/technetwork/java/javase/overview/index.html
Summary : Java Platform Standard Edition Development Kit
Description :
The Java Platform Standard Edition Development Kit (JDK) includes both
the runtime environment (Java virtual machine, the Java platform classes
and supporting files) and development tools (compilers, debuggers,
tool libraries and other tools).
[root@10 ~]#

openjdk

[root@10 ~]# rpm -ql grep java-1.8.0-openjdk-devel-1.8.0.332.b09-2.el8_6.x86_64 | grep javac
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/bin/javac

[root@10 ~]# rpm -qa | grep java
tzdata-java-2022a-1.el8.noarch
java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64
java-1.8.0-openjdk-headless-1.8.0.332.b09-2.el8_6.x86_64
javapackages-filesystem-5.3.0-2.module+el8.3.0+125+5da1ae29.noarch
java-1.8.0-openjdk-devel-1.8.0.332.b09-2.el8_6.x86_64

[root@10 ~]# rpm -qi java-1.8.0-openjdk-devel-1.8.0.332.b09-2.el8_6.x86_64
Name : java-1.8.0-openjdk-devel
Epoch : 1
Version : 1.8.0.332.b09
Release : 2.el8_6
Architecture: x86_64
Install Date: Wed 15 Jun 2022 09:52:45 AM EDT
Group : Development/Tools
Size : 42599147
License : ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Publ ic Domain and W3C and zlib
Signature : RSA/SHA256, Sun 15 May 2022 01:38:09 PM EDT, Key ID 15af5dac6d745a 60
Source RPM : java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.src.rpm
Build Date : Sun 15 May 2022 01:03:19 PM EDT
Build Host : ord1-prod-x86build002.svc.aws.rockylinux.org
Relocations : (not relocatable)
Packager : infrastructure@rockylinux.org
Vendor : Rocky
URL : http://openjdk.java.net/
Summary : OpenJDK 8 Development Environment
Description :
The OpenJDK 8 development tools.

错误代码

这个抽象的类,或者接口类不能实例化。

[root@10 ~]# cat b.java
// Your First Programabstract class Student{
}class HelloWorld {public static void main(String[] args) {System.out.println("Hello, World!");Student a = new Student();}
}

src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties

90 # 0: symbol
91 compiler.err.abstract.cant.be.instantiated=
92 {0} is abstract; cannot be instantiated

小心

如果当前目录之前编译过 student类,就会生成Student.class 文件。
即使当你删除了 java文件里的Student类定义,javac还是会去找 Student.class文件来不足符号找不到的问题。

javac -verbos

显示编译过程信息
[root@10 ~]# javac -verbose b.java
[parsing started RegularFileObject[b.java]]
[parsing completed 114ms]
[search path for source files: .]
[search path for class files: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/resources.jar,/usr/li
b/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/rt.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8
6.x86_64/jre/lib/sunrsasign.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/jsse.jar,/usr/lib/
jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/jce.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8

6.x86_64/jre/lib/charsets.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/jfr.jar,/usr/lib/jvm/
java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/classes,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64
/jre/lib/ext/cldrdata.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/ext/dnsns.jar,/usr/lib/jv
m/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/ext/jaccess.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-
2.el8_6.x86_64/jre/lib/ext/localedata.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/ext/nasho
rn.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/ext/sunec.jar,/usr/lib/jvm/java-1.8.0-openjd
k-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/ext/sunjce_provider.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86
_64/jre/lib/ext/sunpkcs11.jar,/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/jre/lib/ext/zipfs.jar,.]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Object.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/String.class)]]
[checking HelloWorld]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/io/Serializable.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/AutoCloseable.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Byte.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Character.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Short.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Long.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Float.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Integer.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Double.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Boolean.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Void.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/System.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/io/PrintStream.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Appendable.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/io/Closeable.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/io/FilterOutputStream.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/io/OutputStream.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/io/Flushable.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/Comparable.class)]]
[loading ZipFileIndexFileObject[/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-2.el8_6.x86_64/lib/ct.sym(META-INF/sym/rt.
jar/java/lang/CharSequence.class)]]
[loading RegularFileObject[./Student.class]]
b.java:4: error: Student is abstract; cannot be instantiated
Student a = new Student();
^
[total 739ms]

http://www.lryc.cn/news/28771.html

相关文章:

  • 28个案例问题分析---019---临时解决方案和最终解决方案--思想
  • 计算机网络的166个概念你知道几个 第四部分
  • Lenovo 联想-IdeaPad-Y530电脑 Hackintosh 黑苹果efi引导文件
  • mac M1 nvm安装教程,避坑
  • 【项目精选】基于网络爬虫技术的网络新闻分析(视频+论文+源码)
  • 【Python - Matplotlib】P2 plot 折线图
  • 【Verilog】——模块,常量,变量
  • 论文投稿指南——中文核心期刊推荐(电影、电视艺术)
  • Pip install 和Conda install 总结
  • 嵌入式系统实验——【玄武F103开发板】实现两个LED小灯闪烁
  • 数组之双指针题
  • 真实需求和梦想实现满足
  • [ant-design-vue] tree 组件功能使用
  • QT父子窗口事件传递与事件过滤器
  • 【2.4 golang中的循环语句for】
  • Windows 系统下 Apache 和 php 环境怎么搭建?
  • Python基础知识——字符串、字典
  • JVM常用指令
  • 排序中常见的一些指标
  • 51单片机入门————数码管显示
  • Spring事务未生效场景
  • servlet注解开发
  • mysql一联合主键
  • openpnp - 判断吸嘴是否指定了正确的旋转轴
  • 【办公类-19-03】办公中的思考——Python批量统一文件名的序号(保教主任整理打印文件)
  • MySQL约束
  • x86 平台利用 qemu-user-static 实现 arm64 平台 docker 镜像的运行和构建
  • 找工作经验分享
  • C语言学习之路--操作符篇,从知识到实战
  • 【华为OD机试2023】端口合并 C++ Java Python