Java在IntelliJ上运行正常,但在控制台终端上无法运行。

huangapple go评论114阅读模式
英文:

Java work on intelliJ but don't work in console terminal

问题

I tried to run my code on terminal, but when I try to do that, an error like this appears:

javac .\Server.java.\Server.java:27: error: cannot find symbol
                ClientHandler clientHandler = new ClientHandler(socket);
                ^
  symbol:   class ClientHandler
  location: class Server
.\Server.java:27: error: cannot find symbol
                ClientHandler clientHandler = new ClientHandler(socket);
                                                  ^
  symbol:   class ClientHandler
  location: class Server
2 errors

I tried with java, javac, java -jar, java -cp, java -classpath command too.
All not work!

英文:

I tried to run my code on terminal, but when i try to do that appear an error like that:

javac .\Server.java.\Server.java:27: error: cannot find symbol
                ClientHandler clientHandler = new ClientHandler(socket);
                ^
  symbol:   class ClientHandler
  location: class Server
.\Server.java:27: error: cannot find symbol
                ClientHandler clientHandler = new ClientHandler(socket);
                                                  ^
  symbol:   class ClientHandler
  location: class Server
2 errors

I tried with java, javac, java -jar, java -cp, java -classpath command too.
All not work!

答案1

得分: 0

看起来 ClientHandler 不是一个标准库类,它要么是由你编写的类,要么是某个库中的类。在第一种情况下,请不要忘记将所有源代码目录包含到 javac 命令行中,使用 -sourcepath 参数(更多信息可以参考这里)。在第二种情况下,请不要忘记将依赖库作为类路径通过 -cp 参数包含进去(更多信息可以参考这里)。

英文:

Looks like ClientHandler is not an standard library class, it's either written by you class, either a class from some library. In the first case please don't forget to include all source directories to javac command line as -sourcepath (more information for example here). In the second case don't forget to include dependency library as classpath via -cp (more information for example here)

huangapple
  • 本文由 发表于 2023年6月8日 04:41:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76426987.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定