0

I made a package which contains certain java files and I have a java program which uses that package in order to do work. The files within the package all have package test; as their first line. The file that uses the package imports it by import test.*;. I have a make file that looks like this:

....
CLASSES = \
    Client.java \
    test/A.java \
    test/B.java \
    ...

The makefile produces *.class files without any issues. The package is a "server" of sorts, and I need to start an instance of it before I start running the Client. When I say java -cp . A config.properties in the ./test folder, I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: A (wrong name: test/A)    

How can I fix this?

1
  • Sample for the class plz? Commented Nov 1, 2014 at 7:55

1 Answer 1

4

Instead of (in the test folder)

java -cp . A 

you need to go up one directory and

cd ..
java -cp . test.A

to get the A in the test package.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.