Reputation: 1815
The directory of QueryFeatureExtract.java
is like
gen-java/
└── query_feature
└── QueryFeatureExtract.java
and the java file ThriftClient.java
which use QueryFeatureExtract
is in the same folder with gen-java
, I want to compile Client.java
with
javac -classpath libthrift-0.9.1.jar:slf4j.jar -sourcepath gen-java/query_feature/ ThriftClient.java
Then the error shows
ThriftClient.java:16: error: cannot access QueryFeatureExtract
QueryFeatureExtract.Client client = new QueryFeatureExtract.Client(protocol);
^
bad source file: gen-java/query_feature/QueryFeatureExtract.java
file does not contain class QueryFeatureExtract
Please remove or make sure it appears in the correct subdirectory of the sourcepath.
1 error
Upvotes: 1
Views: 6060
Reputation: 3726
Assuming your files are like this:
./
└── ThriftClient.java
└── gen-java/
| └── query_feature/
| └── QueryFeatureExtract.java
└── libthrift-0.9.1.jar
└── slf4j.jar
And QueryFeatureExtract
begins with the following package declaration:
package query_feature;
You should use the following command to compile ThriftClient.java
:
javac -classpath .:libthrift-0.9.1.jar:slf4j.jar:gen-java ThriftClient.java
You can specify folders with -classpath
, you don't need to use -sourcepath
. Don't forget to add .
to your class path if you have other java files in the current folder. To avoid errors since you have a source path containing an other source path, I would recommand moving ThriftClient.java
into a folder named src
.
If it does not work, check that ThriftClient
is importing QueryFeatureExtract
with the correct import:
import query_feature.QueryFeatureExtract;
Upvotes: 2