Skip to content
Advertisement

javac error: “Cannot find symbol”

I’m trying to compile java files on an EC2 instance, and am having trouble. I have several JAR files as well that are included in the classpath. The example would be a StockTrade.java (which is a stock trade object), which compiles completely without issue. In the same directory, there is the StockTradeGenerator.java, which will create StockTrade objects. When I try to compile this, it tells me it cannot find the StockTrade class (despite it being in the same directory already compiled. Specifically, there is a field within my StockTrade object that is a TradeType which is definied as an enum: BUY or SELL in the StockTrade.java code. It says it cannot find the symbol TradeType. My syntax is:

javac -cp lib/jar1.jar:lib/jar2.jar src/StockTradeGenerator.java

Does anyone know what is making it so that I cannot find TradeType when compiling StockTradeGenerator? As I said, its defined in StockTrade.java, which compiled without issue and is in the same folder/directory.

Advertisement

Answer

Put the current directory class path.

javac -cp .:lib/jar1.jar:lib/jar2.jar src/StockTradeGenerator.java

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement