-3

I am attempting to run my program. However, when I click run, no output window shows up. In addition, when I go to View --> Tool Windows, the Run option is disabled. enter image description here

My main class just in case anyone was wondering:

import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import static junit.framework.TestCase.assertEquals;

public class TesterClass {
public static void main(String[] args) {
    String url = "https://erikberg.com/nba/standings.json";
    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet();
    request.addHeader("User-agent", "LotterySimulator/1.0 (nneeranjun@berkeley.edu)");
    HttpResponse response = null;
    try {
        response = client.execute(request);
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        System.out.println(response.getEntity().getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }

}

}
Tom
  • 16,842
  • 17
  • 45
  • 54
nilay neeranjun
  • 145
  • 2
  • 14
  • Has your program a main method? – Jens Aug 23 '18 at 08:15
  • https://www.jetbrains.com/help/idea/creating-and-running-your-first-java-application.html. – CrazyCoder Aug 23 '18 at 08:16
  • Yes I have a main method lol – nilay neeranjun Aug 23 '18 at 17:15
  • I don't understand why the question has 4 downvotes and two answers with one upvote each. How can the question be so bad and those answers so good? –  Aug 23 '18 at 23:00
  • @YvetteColomb "and those answers so good" .. with one upvote each, that's a bit of a stretch. Anyway OP said he has a main method and that he did what the answers suggested, so this is nothing more than a "guessing game". That's not a question suitable for Stackoverflow. – Tom Aug 23 '18 at 23:02
  • @Tom yeh, they're not "so" good. I'm querying the disparity between the up and down votes. My thinking is if the question is not worth upvoting (i.e on topic). it's not worth answering. Or, it a question is worth answering it's worth upvoting. I haven't had coffee yet, don't blame me for my convoluted words, talking thingo :D –  Aug 23 '18 at 23:07
  • @YvetteColomb This thinking works for you as an individual person, but we don't know how many persons acted on this question and if there are people who answered (or upvoted one of the answers) and downvoted the question as well. There are surely also people who still would answer a question even when they downvoted it. – Tom Aug 23 '18 at 23:22

3 Answers3

1

Most probably you don't have a main entry point

  1. Create a new class with any name you see fit.
  2. Type psvm and hit tab, that will generate a main method.
  3. Click on the green play arrow on the left.

enter image description here

Samuel Kodytek
  • 1,004
  • 2
  • 11
  • 23
1

The Run option under View --> Tool Windows is not used to run a program. It is used to toggle display for the run panel. The option is grayed out because there is no panel to currently toggle.

As for running the program, you need to have a run configuration setup with a valid JDK, main class, and module. The main class specified in the run configuration also needs to have the method with signature: public static void main(String[]). Alternatively, if you have the file containing such method open in the editor, you should be able to run it by either clicking the green arrow in the gutter on the left side or by going to Run -> Run "MyClass"

0

You could try this. Go to "Edit Configurations...":

And then select your main class here:

enter image description here

Marc Dirven
  • 309
  • 2
  • 18