EDIT: Worth noting that I think the only thing semantically wrong with your code is that your method name is "getvalue()" instead of "getValue()". Case sensitivity is very important! THAT SAID, you really SHOULD use WCMUsePojo instead of WCMUse.
If you're determined to use Java instead of what's available through JavaScript, this should work for you:
Java Class:
package com.your.pkg.name; import com.adobe.cq.sightly.WCMUsePojo; import org.apache.sling.api.resource.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Created by Greg Wells on 2/7/17. */ public class TestComponent extends WCMUsePojo { private static final Logger LOG = LoggerFactory.getLogger(TestComponent.class); private String value; @Override public void activate() throws Exception { final Resource resource = getResource(); value = resource.getPath(); LOG.info("Value: {}", value); } public String getValue() { return value; } }
HTL Component:
<!--/* Test Component @author Greg Wells */--> <div data-sly-use.testComp="com.your.pkg.name.TestComponent"> <p data-sly-test.value="${ testComp.value }"> <strong>Value from Java:</strong> ${ value } </p> </div>
Let me know if that doesn't work for you.