#Not able to compile java file which is importing another file.

1 messages · Page 1 of 1 (latest)

rich drift
#

My java files are in this format:

  • src/main/magicalArena/MagicalArena.java
  • src/test/magicalArenaTest/MagicalArenaTest.java
    where in MagicalArenaTest.class file I am importing magicalArena.MagicalArena. And compiling both files, after compiling, I have my compiled files in these structure:
  • target/magicalArena/MagicalArena.class
  • target/test/magicalArenaTest/MagicalArenaTest.class

Now how do I run my MagicalArenaTest program?
I am running the command: java -cp target:test magicalArenaTest.MagicalArenaTest
But still getting the error:
Error: Could not find or load main class test.magicalArenaTest.MagicalArenaTest
Caused by: java.lang.ClassNotFoundException: test.magicalArenaTest.MagicalArenaTest

It has been 6 hours, I am still not able to figure out.
Can anybody help?

sleek sorrelBOT
#

<@&987246399047479336> please have a look, thanks.

wooden token
#

@rich drift hmm

#

can you share all the commands you are running?

rich drift
#

Yes sure.
Compiling the files: javac -d target/ src/main/magicalArena/MagicalArena.java; javac -d target/ -cp target/ src/test/magicalArenaTest/MagicalArenaTest.java

wooden token
#

can you share the code itself? i'll try getting it running on my machine first

#

i assume something called "MagicalArena" isn't a trade secret

#

(i'm working on a small example)

#

if you look in the Justfile you should see the commands I ran

#

lmk if this helps

rich drift
#

Thanks a lot for your time.
It worked for me. Now, I am able to compile and run both.

queen meteor