Vscode-code-runner: how can I run JAVA code with CodeRunner?

Created on 3 May 2017  ·  4Comments  ·  Source: formulahendry/vscode-code-runner

Dear all:

I have installed JDK, VSC, and CodeRunner(btw, I have already set the path for JAVA correctly). However, when I try to use CodeRunner, there is always a same error message express: "error: class learn1 is public, should be declared in a file named learn1.java", and please see the picture below.

I am very sure that I named the class which is same as the file name.

http://imgur.com/m52uJua

the whole message is:

[Running] cd "d:\Dropbox\coding\practices\JAVA\src\" && javac temp-msvqqxjdsd.java && java temp-msvqqxjdsd
temp-msvqqxjdsd.java:1: error: class learn1 is public, should be declared in a file named learn1.java
public class learn1 {
^
1 error
[Done] exited with code=1 in 5.295 seconds

I can use the Eclipse Neon for JAVA EE to compile can run the same file correctly. Do I need to setup anything before I use the feature in VSC? VSC is very cool and light, and I really want to use it to learn developing JAVA application. Please help me to figure out this problem. Thank you so much!

question

All 4 comments

Hi @seiferthan , I see you have selected the code. Please do not select the code snippet and try again.

Or, you could use below setting (File->Preference->Settings) to avoid the impact of selection:

{
    "code-runner.ignoreSelection": true
}

@formulahendry
Thank you!!! Your are awesome! I tried to fined the solution for two days, and it seems few of people had faced this problem before.
It's very wonderful to know the tip! Thank you again! :+1:

You are welcome.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bhavinkamani picture bhavinkamani  ·  4Comments

Kelo007 picture Kelo007  ·  3Comments

ranolfi picture ranolfi  ·  3Comments

StayFoolisj picture StayFoolisj  ·  5Comments

Yensan picture Yensan  ·  4Comments