jar和java文件,使用javac编译多个jar和Java文件

I downloaded a sample code written in java that has multiple jar files and java files. I am not a Java programmer so I am having a hard time compiling the code. Here's my attempt:

javac -classpath lib/*.jar src/*.java

However this is what I get:

javac: invalid flag: lib/dom4j-1.6.1.jar

Usage: javac

use -help for a list of possible options

What's wrong with my approach and how can I compile the code? ALl the jar files are located in the lib folder, and the java files in the src folder.

解决方案

You need to stop the shell from globbing the wild-card in lib/*.jar by escaping it.

Also, you need to remove the .jar suffix ... because that's how classpath wildcards work; see Oracle's "Setting the classpath" document.

So ...

javac -classpath lib/\* src/*.java

Using an IDE is another option. However, if all you want to do is compile and run, then downloading and installing and learning to use an IDE is overkill (IMO). And the flipside is that it is good for an IDE-using Java programmer to also understand how to compile and run from the shell prompt ...

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值