1

I am new in java, I have spent hours for this problem. I will be really thankful for anyone who can help me.

Here is the problem.

  1. My project, say ProjectA, need a bunch of libraries to compile, but I don't think I need a library called LibraryB.jar. So the project compiled correctly without LibraryB in the class path.
  2. At runtime, the program exited without any error message. I didn't know the reason until I put LibraryB.jar in classpath when I run my project

Could anyone tell me why this is happening? As I know, in java, If I referenced LibraryB.jar, it would be needed at compile and link time. Maybe I am wrong.

1 Answer 1

1

Lacking concrete examples, I can only give you a high-level overview:

If your project uses LibraryA that depends on LibraryB but does not actually expose any of LibraryB's classes in its interfaces (i.e. it only uses it internally), then you can easily come into a situation where you only need LibraryA to compile, but need LibraryB to actually run your code.

If your application exits without an error message, then it's your own fault, more often than not. Especially for people new to Java, a common cause for this is empty catch-blocks (don't do this!):

try {
  someCodeThatCanThrowAndException();
} catch (Exception e) 7
  // nothing
}
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.