从cmd运行Jar相关的.Java [英] Run Jar related .Java from cmd

查看:167
本文介绍了从cmd运行Jar相关的.Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从cmd promt中执行javac Classname.java,这个Classname.java需要Jfreechart libraries / jars,并且如果从eclipse编译时运行良好(因为项目包已经导入jars)。但我想从cmd提示符运行该文件,它无法显示输出。它有错误像:(包不exsist),如何解决它。我需要类文件和运行JNI命令来创建头文件。请帮帮我。谢谢 。

I am trying to do "javac Classname.java" from cmd promt, and this Classname.java requires Jfreechart libraries/jars, and runs fine if compiled from eclipse (because project package has jars imported). But I want to run the file from cmd prompt and its not able to show me the output. It comes with errors like: ("package doesn't exsist"), how to fix it. I need the class file and also run JNI commands to create header file. Please help me. Thank you .

推荐答案

您需要设置类路径

您可以通过两种方式实现。可以使用 -classpath -cp 选项:

You can do this in 2 ways. Either use the -classpath or -cp option:

javac -cp jar1.jar;path/to/jar2.jar Classname.java

或者,如果你需要它来坚持,使用 CLASSPATH 环境变量:

Or, if you need it to persist, use the CLASSPATH environmental variable:

set CLASSPATH=path1;path2
javac Classname.java

这篇关于从cmd运行Jar相关的.Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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