我该如何使用jar文件? [英] How should i use a jar file?

查看:199
本文介绍了我该如何使用jar文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jar文件,其中包含一些我想在项目中使用的类。我在命令行工作而不是在eclipse中工作。

I have a jar file which contains some classes those which i want to use in my project. I am working in command line and not in eclipse.

请告诉我如何在我的项目的jar文件中使用这些类。

Please tell me how i should use those classes in the jar file for my project.

推荐答案

使用-classpath命令行选项:

Use the -classpath command line option:

javac -classpath library.jar MyProgram.java

然后再运行它,再次指定类路径 - 包括实际代码的位置:

And then to run it, specify the classpath again - including where your actual code is:

java -classpath library.jar;. MyProgram

(假设您正在使用Windows。在Unix上使用:而不是;因为这是路径分隔符。)

(That's assuming you're using Windows. On Unix use : instead of ; as that's the path separator.)

这篇关于我该如何使用jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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