在命令行中创建一个java包 [英] making a java package in the command line

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

问题描述

虽然它可能推荐一个使用和IDE编码高级java项目,我个人更喜欢运行几乎完全命令行(使用gedit作为文本编辑器)。所以请不要只告诉我只要使用eclipse!或某事:P



我的问题是在java中创建包的方法是通过命令。



我不是说打包在命令行运行的应用程序,我说的是在命令行中制作一个包。我在做文本文件吗?



相关地,如何在不使用IDE的情况下链接到相关的库和本地代码?



我知道我在这里真的很尴尬,但我真的更喜欢控件在命令行中工作。

解决方案

packages只是文件系统上的目录。
所以你的包: com.mycompany.util 对应一个目录 com / mycompany / util / p>

运行和编译等时,当前的工作目录应该位于顶层目录所在的位置。



,在编译和运行时将它们包含在类路径中。例如,使一个Project目录 myproject 和下面有您的java文件和包在 myproject / src / 你在 myproject / libs /
下使用当你当前的工作目录是 myproject execute java -cp::libs / *。jar 或与 javac 相同。



但我建议你看看使用ant或maven。


Though it's probably reccomended one uses and IDE for coding advanced java projects, I personally prefer running almost entirely command-line (using gedit as a text-editor). So please don't just tell me "Just use eclipse!" or something :P

My question is what the method of creating a package in java is by a command.

I'm not talking about packaging an application that runs in the command line, I'm talking about making a package in the command line. Am I making a text file? Am I making a directory?

Relatedly, how does one link to related libs and natives without use of an IDE?

I know I'm being really awkward here, but I really prefer the control one gets working in command line.

解决方案

packages are just directories on the filesystem. so your package: com.mycompany.util corresponds to a directory com/mycompany/util.

When running and compiling etc your current workding directory should be where that top directory is located.

To include libraries, include them in your classpath when compiling and running. For example make a Project directory myproject and under that have your java-files and packages under myproject/src/ and libraries that you use under myproject/libs/ Then when your current workding directory is myproject execute java -cp .:libs/*.jar or the same with javac.

But I suggest you look into using ant or maven.

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

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