How can I get a workflow state/status from an external application in java?

Hi Team,
I want to know my workflow state whether it has failed/succeeded/in_progress?
Can you please let me know how can I do it from an external program in java?

The following did it for me:

String workflowId = "c1d901c1-49ca-400b-bb0f-ca5cd9eb35c9";
WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();
WorkflowServiceGrpc.WorkflowServiceBlockingStub stub = service.blockingStub();
DescribeWorkflowExecutionRequest request =
    DescribeWorkflowExecutionRequest.newBuilder()
        .setNamespace("UnitTest")
        .setExecution(WorkflowExecution.newBuilder().setWorkflowId(workflowId))
        .build();
DescribeWorkflowExecutionResponse response = stub.describeWorkflowExecution(request);
System.out.println(response.getWorkflowExecutionInfo().getStatus());

Hi Maxim,
I am using cadence java client sdk (2.7.1),so I am not seeing some classes you wrote above.

Cadence has a similar DescribeWorkflowExecution API. It belongs to WorkflowServiceTChannel.

Thanks Maxim.