设置JAR文件的类路径 [英] Setting the classpath for JAR files

查看:128
本文介绍了设置JAR文件的类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近刚刚创建使用Eclipse,需要2 JAR文件(phiget21.jar和的mysql.jar)

I have recently just created Java project using Eclipse that requires 2 JAR files (phiget21.jar and the mysql.jar)

一切都在Eclipse中运行程序时工作正常,我已经注意到的jar文件都保存在一个'库'的文件夹。

Everything works fine when running the programme in Eclipse, and I have noticed the the jar files are saved in a 'lib' folder.

我很快就要我移动程序关闭我的电脑在其他计算机上使用的,所以我决定创建一个批处理文件编译所有的类,然后运行。

I soon going to me moving the programme off my computer to be used on other machines, so I decided to create a batch file to compile all of the classes and then run.

不过,我有jar文件的定位麻烦。在批处理文件,我需要一个命令是这样的:设置CLASSPATH =:..;的mysql.jar:?../ phidget21.jar,Java类的编译之前

However, I am having trouble with the locating of the jar files. In the batch file do I require a command something like: set classpath=.:..;mysql.jar:../phidget21.jar, before the compilation of the Java classes?

我已经阅读了点(...)必须是与目录,但不完全知道如何实现它们。

I have read that the dots (...) have something to do with directories but not entirely sure how to implement them.

我的方案目前保存在这些位置:

My programme is currently saved in these locations:

项目/ src目录/ .java文件(我也摆在这里的.jar文件以及我认为这可能使事情更容易)

Project/src/.java files (I have also put the .jar files in here as well as i thought this may make thing s easier)

项目/ lib中/ .jar文件

Project/lib/ .jar files

任何帮助将大大AP preciated!

Any help would be greatly appreciated!

推荐答案

而设置类路径的一个点(。)表示当前目录。正如你JAR文件在当前目录下,你只需要在DOS提示符下使用cd命令进入当前目录,然后用

while setting the classpath a single dot (.) means current directory. As you jar files are in current directory, you just need to go to your current directory using cd command in DOS prompt, then use

set classpath = .;filename.jar;another filename.jar

下面。再presents当前目录和各分号分隔类路径。

Here . represents current directory and semicolon separates each classpaths.

您甚至可以设置这可以理解为使用通配符*不止一个jar文件的类路径的所有

You can even set classpath of more than one jar files using wild card character * which can be read as all.

这篇关于设置JAR文件的类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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