So I was following this tutorial: https://spring.io/guides/gs/maven/
I cloned their repositories for the software for fear of mistyping something.
The code does not work when I compile Greeter.java using javac and then use java to run HelloWorld.java file It gives me the following error:
HelloWorld.java:5: error: cannot find symbol
Greeter greeter = new Greeter();
^
symbol: class Greeter
location: class HelloWorld
HelloWorld.java:5: error: cannot find symbol
Greeter greeter = new Greeter();
^
symbol: class Greeter
location: class HelloWorld
2 errors
I tried explicitly importing Greeter into HelloWorld using
ìmport hello.Greeter
The code works fine when I run it without the package hello;statements.
Any idea why I am getting this error??
So I followed through with the tutorial and using mvn package command and the jar file generated the project works.
So is this issue with trying to compile it with java command in the command line.
Adding directory structure of the project
pom.xml src target
./src:
main
./src/main:
java
./src/main/java:
hello
./src/main/java/hello:
Greeter.java HelloWorld.java
Greeter, you will not be able to run theHelloWorldclass either. Makes sense! Now, how are you trying to compile the greeter class? What is your working directory and what is your javac command?