Netbeans programmatically add watch expression to the "watch window"

use this code

import org.netbeans.api.debugger.DebuggerManager;
DebuggerManager.getDebuggerManager().createWatch("your expression, e.g. variable name");

pom.xml


	<dependencies>
		<dependency>
			<groupId>org.netbeans.api</groupId>
			<artifactId>org-netbeans-api-annotations-common</artifactId>
			<version>RELEASE170</version>
		</dependency>
		<dependency>
			<groupId>org.netbeans.api</groupId>
			<artifactId>org-openide-util</artifactId>
			<version>RELEASE170</version>
		</dependency>
		<dependency>
			<groupId>org.netbeans.api</groupId>
			<artifactId>org-openide-awt</artifactId>
			<version>RELEASE170</version>
		</dependency>
		<dependency>
			<groupId>org.netbeans.api</groupId>
			<artifactId>org-netbeans-api-debugger</artifactId>
			<version>RELEASE170</version>
		</dependency>
		<dependency>
			<groupId>org.netbeans.api</groupId>
			<artifactId>org-netbeans-spi-debugger-ui</artifactId>
			<version>RELEASE170</version>
		</dependency>
	</dependencies>