在 Java 中使用命令行编译多个包 [英] Compiling multiple packages using the command line in Java

查看:36
本文介绍了在 Java 中使用命令行编译多个包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 IDE,但现在我需要从命令行运行和编译.

Hi i have been using an IDE but now I need to run and compile from the command line.

问题是我有多个包,我试图找到答案,但没有任何效果.

The problem is that I have multiple packages and I have tried to find the answer but nothing has worked.

所以我有

src/
  Support/ (.java files)
  Me/ (.java files) 
  Wrapers/ (.java files)  

你知道如何用 javac 编译所有东西吗?

Do you know how to compile everything with javac?

推荐答案

应该这样做(可能需要通过 -cp 命令行开关添加额外的类路径元素):

This should do it (may require additional classpath elements via the -cp command line switch):

javac Support/*.java Me/*.java Wrapers/*.java

但是如果您的构建过程变得更加复杂(而且会变得更加复杂!),您应该考虑使用 Apache Ant 用于构建自动化.

But if your build process gets more complex (and it will!), you should look into using Apache Ant for build automation.

这篇关于在 Java 中使用命令行编译多个包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆