Eyal Zinder
Eyal Zinder

Reputation: 664

Debugging Java with JDB and Gradle

I have a simple 'HelloWorld' class within a small project that was initiated with Gradle (gradle init --type java-library). The HelloWorld.java file is located in [project]/src/main/java/HelloWorld.java. The project gets compiled when I run "gradle build" / "gradle compileJava", etc.

I am trying to debug it using JDB. I've tried: %jdb -sourcepath src/main/java HelloWorld %jdb run HelloWorld etc..

I am getting "Error: Could not find or load main class Program"

What am I doing wrong?

Upvotes: 1

Views: 1380

Answers (1)

Oo.oO
Oo.oO

Reputation: 13375

Make sure to add class path as well.

-sourcepath provides jdb with location of *.java
-classpath provides jdb with location of *.class

You have to call it like this:

jdb -sourcepath src/main/java -classpath _location_of_compiled_code_ HelloWorld

Upvotes: 1

Related Questions