英文:
Unable to import JAR files?
问题
我需要一个特定的JAR文件来执行代码。我可以通过将JAR文件添加到库中在eclipse中运行代码。
但是当我从命令提示符运行代码时,我会收到错误,指出无法导入javax.jms(该jar文件)。
C:\tibco\ems\8.5\samples\java\JNDI>javac tibjmsJNDIFT.java
tibjmsJNDIFT.java:43: error: package javax.jms does not exist
import javax.jms.*;
^
tibjmsJNDIFT.java:108: error: cannot find symbol
ConnectionFactory connectionFactory =
^
symbol: class ConnectionFactory
location: class tibjmsJNDIFT
tibjmsJNDIFT.java:109: error: cannot find symbol
(ConnectionFactory)jndiContext.lookup(factory[j]);
^
symbol: class ConnectionFactory
location: class tibjmsJNDIFT
3 errors
C:\tibco\ems\8.5\samples\java\JNDI>
英文:
I need a particular JAR file, fo execute a code. I am able to run the code In eclipse by adding the JAR file to libraries.
But when I run he code from cmd prompt I get error saying unable to import javax.jms(the jar file).
C:\tibco\ems.5\samples\java\JNDI>javac tibjmsJNDIFT.java
tibjmsJNDIFT.java:43: error: package javax.jms does not exist
import javax.jms.*;
^
tibjmsJNDIFT.java:108: error: cannot find symbol
ConnectionFactory connectionFactory =
^
symbol: class ConnectionFactory
location: class tibjmsJNDIFT
tibjmsJNDIFT.java:109: error: cannot find symbol
(ConnectionFactory)jndiContext.lookup(factory[j]);
^
symbol: class ConnectionFactory
location: class tibjmsJNDIFT
3 errors
C:\tibco\ems.5\samples\java\JNDI>
答案1
得分: 1
你应该使用"-cp"或"-classpath"选项:
javac -cp ".:/path/to/jms.jar:/path/to/any-other.jar" tibjmsJNDIFT.java
在Windows操作系统上,你可能需要使用"分号" (;) 而不是"冒号" (:)
英文:
You should use the "-cp" or "-classpath" option:
javac -cp ".:/path/to/jms.jar:/path/to/any-other.jar" tibjmsJNDIFT.java
On Windows OS you might have to use "semicolons" (;) instead of "colons" (:)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论