我的课程路径是:
:.:/usr/share/java/*:/usr/share/tomcat7/lib/servlet-api.jar
编辑:
如果我将类路径设置为
,IT也不起作用:.:/usr/share/java/:/usr/share/tomcat7/lib/servlet-api.jar
或者
:.:/usr/share/java:/usr/share/tomcat7/lib/servlet-api.jar
我知道该目录包含我想要使用的类的正确jar,但javac仍然给我错误:
javac util/GSpreadsheets.java
GSpreadsheets.java:1: package com.google.gdata does not exist
import com.google.gdata.*;
^
GSpreadsheets.java:12: cannot find symbol
symbol : class SpreadsheetService
location: class GSpreadsheets
SpreadsheetService myService = null;
^
GSpreadsheets.java:27: cannot find symbol
symbol : class SpreadsheetFeed
location: class GSpreadsheets
public SpreadsheetFeed getEventFeed() throws IOException,ServiceException{
^
GSpreadsheets.java:19: cannot find symbol
symbol : class SpreadseetService
location: class GSpreadsheets
myService = new SpreadseetService("cl", "exampleCo-exampleApp-1");
^
GSpreadsheets.java:28: cannot find symbol
symbol : variable metafeedUrl
location: class GSpreadsheets
return service.getFeed(metafeedUrl, SpreadsheetFeed.class);
^
GSpreadsheets.java:28: cannot find symbol
symbol : class SpreadsheetFeed
location: class GSpreadsheets
return service.getFeed(metafeedUrl, SpreadsheetFeed.class);
^
GSpreadsheets.java:28: cannot find symbol
symbol : variable service
location: class GSpreadsheets
return service.getFeed(metafeedUrl, SpreadsheetFeed.class);
^
7 errors
如果手动指定jar我需要使用-cp它有时会起作用。但是如果使用-cp我必须手动指定我想要使用的每个jar。这是屁股的痛苦。
目录包含。
ls /usr/share/java/
activation-1.1.1.jar commons-digester.jar inetlib.jar lucene-spellchecker-2.9.4.jar
activation.jar commons-el-1.0.jar jasper-5.5.26.jar lucene-spellchecker.jar
ant-1.8.2.jar commons-el.jar jaxp-1.3.jar lucene-surround-2.9.4.jar
ant-antlr-1.8.2.jar commons-httpclient-3.1.jar jcl-over-slf4j-1.6.1.jar lucene-surround.jar
ant-antlr.jar commons-httpclient.jar jcl-over-slf4j.jar lucene-swing-2.9.4.jar
ant-apache-bcel-1.8.2.jar commons-logging-1.1.1.jar jetty-6.1.24.jar lucene-swing.jar
ant-apache-bcel.jar commons-logging-adapters-1.1.1.jar jetty.jar lucene-wikipedia-2.9.4.jar
ant-apache-bsf-1.8.2.jar commons-logging-adapters.jar jetty-sslengine-6.1.24.jar lucene-wikipedia.jar
ant-apache-bsf.jar commons-logging-api-1.1.1.jar jetty-sslengine.jar lucene-wordnet-2.9.4.jar
ant-apache-log4j-1.8.2.jar commons-logging-api.jar jetty-start-6.1.24.jar lucene-wordnet.jar
ant-apache-log4j.jar commons-logging.jar jetty-start-daemon-6.1.24.jar lucene-xml-query-parser-2.9.4.jar
ant-apache-oro-1.8.2.jar commons-pool-1.5.6.jar jetty-start-daemon.jar lucene-xml-query-parser.jar
ant-apache-oro.jar commons-pool.jar jetty-start.jar mysql-5.1.10.jar
ant-apache-regexp-1.8.2.jar db-5.1.25.jar jetty-util5-6.1.24.jar mysql-connector-java-5.1.10.jar
ant-apache-regexp.jar db.jar jetty-util5.jar mysql-connector-java.jar
ant-apache-resolver-1.8.2.jar db-je-3.3.62.jar jetty-util-6.1.24.jar mysql.jar
ant-apache-resolver.jar db-je.jar jetty-util.jar org.eclipse.osgi_3.7.0.dist.jar
ant-apache-xalan2-1.8.2.jar ecj.jar jline-0.9.94.jar org.eclipse.osgi.jar
ant-apache-xalan2.jar eclipse-ecj-3.5.1.jar jline.jar org.eclipse.osgi.services_3.3.0.dist.jar
ant-bootstrap.jar eclipse-ecj.jar jsch-0.1.42.jar org.eclipse.osgi.services.jar
ant-commons-logging-1.8.2.jar el-api-2.1.jar jsch.jar org.eclipse.osgi.util_3.2.200.dist.jar
ant-commons-logging.jar gdata-analytics-2.1.jar jsp-api-2.0.jar org.eclipse.osgi.util.jar
ant-commons-net-1.8.2.jar gdata-analytics-meta-2.1.jar jsp-api-2.1.jar org.sat4j.core-2.3.0.jar
ant-commons-net.jar gdata-appsforyourdomain-1.0.jar jsp-api.jar org.sat4j.core.jar
ant.jar gdata-appsforyourdomain-meta-1.0.jar jtidy-8.0-alpha-20110807.jar org.sat4j.pb-2.3.0.jar
ant-javamail-1.8.2.jar gdata-base-1.0.jar jtidy.jar org.sat4j.pb.jar
ant-javamail.jar gdata-blogger-2.0.jar jul-to-slf4j-1.6.1.jar regexp-1.5.jar
ant-jdepend-1.8.2.jar gdata-blogger-meta-2.0.jar jul-to-slf4j.jar regexp.jar
ant-jdepend.jar gdata-books-1.0.jar junit-3.8.2.jar sat4j-pb-2.3.0.jar
ant-jmf-1.8.2.jar gdata-books-meta-1.0.jar junit4-4.8.2.jar sat4j-pb.jar
ant-jmf.jar gdata-calendar-2.0.jar junit4.jar servlet-api-2.4.jar
ant-jsch-1.8.2.jar gdata-calendar-meta-2.0.jar junit.jar servlet-api-2.5.jar
ant-jsch.jar gdata-client-1.0.jar lib servlet-api.jar
ant-junit-1.8.2.jar gdata-client.jar libgcj-4.6.1.jar slf4j-api-1.6.1.jar
ant-junit.jar gdata-client-meta-1.0.jar libgcj-4.6.jar slf4j-api.jar
ant-launcher-1.8.2.jar gdata-codesearch-2.0.jar libgcj-tools-4.6.1.jar slf4j-jcl-1.6.1.jar
ant-launcher.jar gdata-codesearch-meta-2.0.jar libgcj-tools-4.6.jar slf4j-jcl.jar
ant-swing-1.8.2.jar gdata-contacts-3.0.jar libintl.jar slf4j-jdk14-1.6.1.jar
ant-swing.jar gdata-contacts-meta-3.0.jar log4j-over-slf4j-1.6.1.jar slf4j-jdk14.jar
ant-testutil-1.8.2.jar gdata-core-1.0.jar log4j-over-slf4j.jar slf4j-log4j12-1.6.1.jar
ant-testutil.jar gdata-docs-3.0.jar lucene-analyzers-2.9.4.jar slf4j-log4j12.jar
asm3-3.3.2.jar gdata-docs-meta-3.0.jar lucene-analyzers.jar slf4j-migrator-1.6.1.jar
asm3-all-3.3.2.jar gdata-finance-2.0.jar lucene-ant-2.9.4.jar slf4j-migrator.jar
asm3-all.jar gdata-finance-meta-2.0.jar lucene-ant.jar slf4j-nop-1.6.1.jar
asm3-analysis-3.3.2.jar gdata-gtt-2.0.jar lucene-bdb-2.9.4.jar slf4j-nop.jar
asm3-analysis.jar gdata-gtt-meta-2.0.jar lucene-bdb.jar slf4j-simple-1.6.1.jar
asm3-commons-3.3.2.jar gdata-health-2.0.jar lucene-bdb-je-2.9.4.jar slf4j-simple.jar
asm3-commons.jar gdata-health-meta-2.0.jar lucene-bdb-je.jar tomcat-annotations-api-7.0.21.jar
asm3-debug-all-3.3.2.jar gdata-maps-2.0.jar lucene-benchmark-2.9.4.jar tomcat-annotations-api.jar
asm3-debug-all.jar gdata-maps-meta-2.0.jar lucene-benchmark.jar tomcat-api-7.0.21.jar
asm3.jar gdata-media-1.0.jar lucene-collation-2.9.4.jar tomcat-api.jar
asm3-tree-3.3.2.jar gdata-photos-2.0.jar lucene-collation.jar tomcat-catalina-7.0.21.jar
asm3-tree.jar gdata-photos-meta-2.0.jar lucene-core-2.9.4.jar tomcat-catalina-ha-7.0.21.jar
asm3-util-3.3.2.jar gdata-projecthosting-2.1.jar lucene-core.jar tomcat-catalina-ha.jar
asm3-util.jar gdata-projecthosting-meta-2.1.jar lucene-fast-vector-highlighter-2.9.4.jar tomcat-catalina.jar
asm3-xml-3.3.2.jar gdata-sidewiki-2.0.jar lucene-fast-vector-highlighter.jar tomcat-coyote-7.0.21.jar
asm3-xml.jar gdata-sidewiki-meta-2.0.jar lucene-highlighter-2.9.4.jar tomcat-coyote.jar
catalina-ant-7.0.21.jar gdata-sites-2.0.jar lucene-highlighter.jar tomcat-el-api-2.2.jar
catalina-ant.jar gdata-sites-meta-2.0.jar lucene-instantiated-2.9.4.jar tomcat-i18n-es-7.0.21.jar
catalina-tribes-7.0.21.jar gdata-spreadsheet-3.0.jar lucene-instantiated.jar tomcat-i18n-es.jar
catalina-tribes.jar gdata-spreadsheet-meta-3.0.jar lucene-lucli-2.9.4.jar tomcat-i18n-fr-7.0.21.jar
com.ibm.icu-4.0.1.1.jar gdata-webmastertools-2.0.jar lucene-lucli.jar tomcat-i18n-fr.jar
com.ibm.icu-4.4.jar gdata-webmastertools-meta-2.0.jar lucene-memory-2.9.4.jar tomcat-i18n-ja-7.0.21.jar
com.ibm.icu.base-4.0.1.1.jar gdata-youtube-2.0.jar lucene-memory.jar tomcat-i18n-ja.jar
com.ibm.icu.base-4.4.jar gdata-youtube-meta-2.0.jar lucene-misc-2.9.4.jar tomcat-jasper-7.0.21.jar
com.ibm.icu.base.jar gnome-java-bridge.jar lucene-misc.jar tomcat-jasper-el-7.0.21.jar
com.ibm.icu.jar gnumail-1.1.2.jar lucene-queries-2.9.4.jar tomcat-jasper-el.jar
commons-beanutils-1.8.3.jar gnumail.jar lucene-queries.jar tomcat-jasper.jar
commons-beanutils.jar gnumail-providers-1.1.2.jar lucene-queryparser-2.9.4.jar tomcat-jsp-api-2.2.jar
commons-codec-1.5.jar gnumail-providers.jar lucene-queryparser.jar tomcat-juli-7.0.21.jar
commons-codec.jar hamcrest-core-1.1.jar lucene-regex-2.9.4.jar tomcat-juli.jar
commons-collections3-3.2.1.jar hamcrest-core.jar lucene-regex.jar tomcat-servlet-api-3.0.jar
commons-collections3.jar hamcrest-generator-1.1.jar lucene-remote-2.9.4.jar tomcat-util-7.0.21.jar
commons-collections3-testframework-3.2.1.jar hamcrest-generator.jar lucene-remote.jar tomcat-util.jar
commons-collections3-testframework.jar hamcrest-integration-1.1.jar lucene-smartcn-2.9.4.jar xercesImpl-2.9.1.jar
commons-compress-1.0.jar hamcrest-integration.jar lucene-smartcn.jar xercesImpl.jar
commons-compress.jar hamcrest-library-1.1.jar lucene-snowball-2.9.4.jar xml-apis-1.3.04.jar
commons-dbcp-1.4.jar hamcrest-library.jar lucene-snowball.jar xml-apis.jar
commons-dbcp.jar icu4j.jar lucene-spatial-2.9.4.jar xmlParserAPIs.jar
另外注意为什么代码块不符合新行字符?
答案 0 :(得分:1)
您可以使用以下语法来包含类路径中特定目录中存在的所有jar。
export CLASSPATH=$CLASSPATH:$(find $REQUIRED_DIRECTORY -name "*.jar"|tr "\n" ":")
答案 1 :(得分:-1)
您不能在类路径中使用*。你应该单独指定每个罐子。