Title: Error: Could not find or load main class · Issue #1085 · redhat-developer/vscode-java · GitHub
Open Graph Title: Error: Could not find or load main class · Issue #1085 · redhat-developer/vscode-java
X Title: Error: Could not find or load main class · Issue #1085 · redhat-developer/vscode-java
Description: When running the Java program by clicking "Run" on top of the static main function, it reports "Could not find or load the main class: xxx". However, directly invoking java with the source file works without any error. I tried to use the...
Open Graph Description: When running the Java program by clicking "Run" on top of the static main function, it reports "Could not find or load the main class: xxx". However, directly invoking java with the source file wor...
X Description: When running the Java program by clicking "Run" on top of the static main function, it reports "Could not find or load the main class: xxx". However, directly invoking java with...
Opengraph URL: https://github.com/redhat-developer/vscode-java/issues/1085
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error: Could not find or load main class","articleBody":"When running the Java program by clicking \"Run\" on top of the static main function, it reports \"Could not find or load the main class: xxx\". However, directly invoking java with the source file works without any error. I tried to use the \"Java: Clean the Java Language Server Workspace\" command, and error persists.\r\n\r\nBy looking at the log (, here are two errors reported that may be the cause of the issue:\r\n\r\n```\r\n[2019-10-02 16:48:22.718] [exthost] [error] [redhat.java] provider FAILED\r\n[2019-10-02 16:48:22.720] [exthost] [error] Error: The request (id: 28, method: 'textDocument/hover') has been cancelled\r\n\tat c:\\Users\\tingh\\.vscode\\extensions\\redhat.java-0.50.0\\dist\\extension.js:1:68555\r\n\tat c:\\Users\\tingh\\.vscode\\extensions\\redhat.java-0.50.0\\dist\\extension.js:1:68849\r\n\tat Immediate.module.exports.M.G.Y.size.setImmediate (c:\\Users\\tingh\\.vscode\\extensions\\redhat.java-0.50.0\\dist\\extension.js:1:69210)\r\n\tat runCallback (timers.js:694:18)\r\n\tat tryOnImmediate (timers.js:665:5)\r\n\tat processImmediate (timers.js:647:5)\r\n[2019-10-02 16:48:23.302] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.cpptools {\"startup\":false,\"activationEvent\":\"onDebug\"}\r\n[2019-10-02 16:48:23.302] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/tingh/.vscode/extensions/ms-vscode.cpptools-0.25.1/dist/main\r\n[2019-10-02 16:48:23.429] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-server-ready {\"startup\":false,\"activationEvent\":\"onDebugResolve\"}\r\n[2019-10-02 16:48:23.429] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/debug-server-ready/dist/extension\r\n```\r\n\r\n##### Environment\r\n- Operating System: Windows 10 x64 Pro 1903, Build 18362.356\r\n- JDK version: Oracle Java 12.0.2\r\n- Visual Studio Code version: 1.38.1\r\n- Java extension version: 0.50.0\r\n\r\n##### Steps To Reproduce\r\nSample Project: (FileIO.java)\r\n```java\r\nimport java.io.File;\r\nimport java.io.IOException;\r\nimport java.util.Scanner;\r\n\r\npublic class FileIO {\r\n\r\n public static void main(String[] args)\r\n throws IOException {\r\n File file = new File(\"data.txt\");\r\n Scanner fileInput = new Scanner(file);\r\n\r\n for(int i = 0; i \u003c 5; i++) {\r\n System.out.println(\r\n i + \": \" + fileInput.nextDouble()\r\n );\r\n }\r\n\r\n fileInput.close();\r\n }\r\n}\r\n```\r\n\r\n##### Current Result\r\n```\r\nc:\\Research\\test_jav>cd C:\\Research\\test_jav && C:\\Users\\tingh\\.vscode\\extensions\\vscjava.vscode-java-debug-0.22.0\\scripts\\launcher.bat \"C:\\Program \r\nFiles\\Java\\jdk-12.0.2\\bin\\java\" --enable-preview -Dfile.encoding=UTF-8 -cp C:\\Users\\tingh\\AppData\\Roaming\\Code\\User\\workspaceStorage\\24ee80637ed5c707879e2f0bc2507a43\\redhat.java\\jdt_ws\\jdt.ls-java-project\\bin FileIO\r\nError: Could not find or load main class FileIO\r\nCaused by: java.lang.ClassNotFoundException: FileIO\r\n```\r\n\r\n##### Expected Result\r\n```\r\nc:\\Research\\test_jav>\"C:\\Program Files\\Java\\jdk-12.0.2\\bin\\java\" FileIO.java\r\n0: 11.0\r\n1: 22.0\r\n2: 33.0\r\n3: 44.0\r\n4: 55.0\r\n```\r\n\r\n##### Additional Informations\r\n","author":{"url":"https://github.com/TinghuiWang","@type":"Person","name":"TinghuiWang"},"datePublished":"2019-10-02T23:51:23Z","url":"https://github.com/redhat-developer/vscode-java/issues/1085"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ee72faf1-6518-de54-8147-99b954fdf336 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5F0:2D075:3E90:4EE5:6B0734A3 |
| html-safe-nonce | 4b1c17b3f6716cbd6773cfb18f113dde379ed7e8be29fbe9b6c83dd98c9cc07e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUYwOjJEMDc1OjNFOTA6NEVFNTo2QjA3MzRBMyIsInZpc2l0b3JfaWQiOiIyMjA0NjQ3NzY2MTI5ODQ5NTA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 54b77ca8149c57a6047cc2ff4b3fe5d1c26df7fff4f7e7711c0f478a84c4e548 |
| hovercard-subject-tag | issue:501781230 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/redhat-developer/vscode-java/1085/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0e0a3cff4244e7bd8d2c8e6df5974e5651c92cf51ab64c5a3a4f6681c4e1a4e0/redhat-developer/vscode-java/issues/1085 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0e0a3cff4244e7bd8d2c8e6df5974e5651c92cf51ab64c5a3a4f6681c4e1a4e0/redhat-developer/vscode-java/issues/1085 |
| og:image:alt | When running the Java program by clicking "Run" on top of the static main function, it reports "Could not find or load the main class: xxx". However, directly invoking java with the source file wor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TinghuiWang |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2a60952cad7efb2604ea85e500208f51c1ec1943aa260ac605c13eb46a1ed83b |
| turbo-cache-control | no-preview |
| go-import | github.com/redhat-developer/vscode-java git https://github.com/redhat-developer/vscode-java.git |
| octolytics-dimension-user_id | 11033755 |
| octolytics-dimension-user_login | redhat-developer |
| octolytics-dimension-repository_id | 65561709 |
| octolytics-dimension-repository_nwo | redhat-developer/vscode-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 65561709 |
| octolytics-dimension-repository_network_root_nwo | redhat-developer/vscode-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 345c27626db08417fdfc84278a4415ae9a48d8f3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width