idea如何编译java文件路径,如何在IDEA中使用类路径而不是模块路径运行Java 9应用程序?...

当在IntelliJ IDEA中运行带有module-info的主类时,它会将模块及其依赖项放在模块路径上。如果希望改为类路径,由于你已经有了module-info,这需要手动配置。通常,你需要将依赖项处理为自动模块。然而,某些依赖项可能需要留在类路径上。这篇内容讨论了如何在命令行通过指定类路径来运行整个应用,并提供了在IDEA中目前不支持此操作的临时解决方案。
摘要由CSDN通过智能技术生成

When I run a main class in IDEA, it puts the module and its dependencies on a module path. Is it possible to change it to a classpath?

解决方案

If you don't define a module-info, IDEA would set the application and your dependencies on the classpath. Since you have a module-info it's an explicit module so it has to be on the module path. Normally you would handle your dependecies now as automatic-modules.

Howsoever, your dependencies at least have a good reason to be on the classpath. We discussed that here Why Java 9 does not simply turn all JARs on the class path into automatic modules?

For example, mymodule depends on an automatic-module which however needs a jar that can't become an automatic-module yet. On commandline it would like this:

java -cp legacy.jar -p "mymodule.jar;automodule.jar;" -m mymodule/com.example.mymodule.Application

IMO intellij doesn't currently support that. As a workaround to run the entire application on the classpath at least, you could rename the model-info for disabling/not to be a jigsaw-module for a moment.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值