How to set a Namespace for a Temporal Client in Java
Use the setNamespace() method on Workflow Client Options Builder.
WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();
WorkflowClientOptions clientOptions = WorkflowClientOptions.newBuilder()
        .setNamespace("your-custom-namespace").build();
WorkflowClient workflowClient =  WorkflowClient.newInstance(service, clientOptions);