在linux下写了一个非常简单的Hello world程序,编译运行竟然报错:Error: Could not find or load main class Hello

最后发现是CLASSPATH的问题。

首先需要检查jdk环境变量是否配置正确:参考这篇文章:ubuntu12.04 安装配置jdk1.7

主要在环境变量这块:

[html] view plaincopy print?
  1. export JAVA_HOME=/usr/java/jdk1.8.0
  2. export JRE_HOME=${JAVA_HOME}/jre
  3. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
  4. export PATH=${JAVA_HOME}/bin:$PATH

我的环境变量之前配置错了,所以修改完以后,source /etc/profile 重新加载一下这个文件,ok,现在就不会报错了!

Linux 下 Error: Could not find or load main class Hello world相关推荐

  1. 运行Linux脚本时候出现Error: Could not find or load main class和No such file or directory错误信息

    在运行Linux脚本文件时,出现了Error: Could not find or load main class和No such file or directory 错误,但是我可以确认jar包中是 ...

  2. java报错-找不到或无法加载主类(Error: Could not find or load main class)

    此文首发于我的个人博客:java报错-找不到或无法加载主类(Error Could not find or load main class) - zhang0peter的个人博客 比如说test.ja ...

  3. Error: Could not find or load main class

    在 java 编程中如果遇到此错误,那么检查下 classpath. 必须确保把 .class 文件的路径添加到 classpath 中, 如果是在当前路径,那么就添加字符 . 到 classpath ...

  4. Sqoop找不到主类 Error: Could not find or load main class org.apache.sqoop.Sqoop

    最近由于要使用Sqoop来到出数据到hdfs,可是发现Sqoop1.4.5跟hadoop2.X不兼容,需要对Sqoop1.4.5进行编译,编译的具体方法见:http://my.codeweblog.c ...

  5. Error: Could not find or load main class CLASS的解决方法

    问题描述: 在linux(centos)云服务器上安装好Java环境,java -version都正常,可以生成.class文件,但执行java tang时出现Error: Could not fin ...

  6. Error: Could not find or load main class org.apache.tez.dag.app.DAGAppMaster

    Error: Could not find or load main class org.apache.tez.dag.app.DAGAppMaster $HADOOP_HOME/etc/hadoop ...

  7. Java运行报错:Error: Could not find or load main class

    [问题描述] 用户root在/root/Exercise文件夹中创建HelloWorld.java 文件,代码如下: 将该文件编译.运行如下: 编译HelloWorld.java生成字节码文件Hell ...

  8. 【Hadoop遇到的坑】运行hadoop自带的例子报错 Error: Could not find or load main class org.apache.hadoop.mapred.YarnCh

    原创不易,未经允许,请勿转载. 博客主页:https://xiaojujiang.blog.csdn.net/ 2021-05-09 22:31:33,652 INFO client.RMProxy: ...

  9. Error: Could not find or load main class XXX 或 Main class cannot resolve XXX

    非maven项目,简简单单的Scala Object main函数调方法,想run或debug起来,结果idea报错 Error: Could not find or load main class ...

最新文章

  1. 部署exchange邮件系统的边缘服务器
  2. 微软如何在3年内将数据中心的用水量削减95%
  3. A strange lift HDU - 1548(基础广搜)
  4. OGRE分析之设计模式
  5. 编程之美3——N!末尾有多少个0
  6. mycli mysql_MyCLI :易于使用的 MySQL/MariaDB 客户端
  7. android 动态单选,添加单选按钮动态︰android
  8. 免费python课程排行榜-Python基础练习(一)中国大学定向排名爬取
  9. GPU视频压缩1—Flexible CTU-level parallel motion estimation by CPU and GPU pipeline for HEVC
  10. npm包rimraf介绍
  11. c语言写抢QQ红包软件,Android实现QQ抢红包插件
  12. bzoj 4417: [Shoi2013]超级跳马
  13. Android APPLogo图片切图大小
  14. UIP协议栈笔记·一
  15. python导入模块失败_关于python导入模块失败的问题
  16. 墨盒 连供漏墨恒压问题
  17. NOI2018 游记
  18. 什么样的域名才能算短域名?短域名还能有吗?
  19. C# 在win10/win11调用默认浏览器打开网页
  20. Seata源码走读分析

热门文章

  1. 实战 Windows Server 2012 群集共享卷
  2. 承载物联之城 阿里云为无锡建设统一物联网基础平台
  3. lnmp之PDO_mysql.so
  4. 记录:网络通信协议中的TCP/IP与UDP
  5. 温习ASP调用C#的DLL并实现用户名密码进行域验证反馈结果
  6. 为什么不早一点告诉我?——情场篇
  7. 微软9月补丁星期二值得关注的0day、终于落幕的 PrintNightmare及其它
  8. WebLogic UniversalExtractor反序列化漏洞(CVE-2020-14645)的复现和分析
  9. 亲历漏洞研究最让人难受的地方:看到打补丁版本,才知漏洞一直近在眼前(详述)...
  10. 关于CVE-2020-14882,你需要知道的都在这里