加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

将Scala应用程序作为Java应用程序运行

发布时间:2020-12-16 08:58:26 所属栏目:安全 来源:网络整理
导读:我正在尝试运行以下火箭发射应用程序: object HelloWorld { def main(args: Array[String]) { println("Hello World!") }} 直接从java这样: java -cp scala-library.jar HelloWorld (显然在用scala编译之后) 但得到以下错误: Exception in thread "main"
我正在尝试运行以下火箭发射应用程序:

object HelloWorld {
    def main(args: Array[String]) {
        println("Hello World!")
    }
}

直接从java这样:

java -cp scala-library.jar HelloWorld

(显然在用scala编译之后)

但得到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
        at java.net.URLClassLoader$1.run(Unknown Source)
(...)
Could not find the main class: HelloWorld.  Program will exit.

我是否已经监督了我需要做些什么才能让它发挥作用?

解决方法

从 Java documentation:

The default class path is the current
directory. Setting the CLASSPATH
variable or using the -classpath
command-line option overrides that
default,so if you want to include the
current directory in the search path,
you must include “.” in the new
settings.

添加.:(或.;在Windows上)到类路径的开头应该有效.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读