formulahendry / formulahendry/vscode-code-runner
Error: Could not find or load main class HelloWorld Caused by: java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/coderunner/javaapp/HelloWorld)
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 351
- PR merge metrics
- No merged PRs in 30d
Description
- VS Code Version:1.8.8.1
- OS Version: 14.x
- Code Runner Version: 1.12.2
**Describe the bug**
Description of what the bug is.
Error: Could not find or load main class HelloWorld
Caused by: java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/coderunner/javaapp/HelloWorld)
**To Reproduce**
Steps to reproduce the behavior:
1. Create Folder JavaWithPackage
2. Create Package com.coderunner.javaapp
3. Create a HelloWorld.java
4. ```
package com.coderunner.javaapp;
/**
* HelloWorld
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello Code Runner!");
}
}
```
5. Run using Code Runner Plugin
**Actual behavior**
Description of what happened actually.
[Done] exited with code=1 in 1.711 seconds
```
[Running] cd "/Users/sri/Downloads/JavaWithPackage/com/coderunner/javaapp/" && javac HelloWorld.java && java -classpath . HelloWorld
Error: Could not find or load main class HelloWorld
Caused by: java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/coderunner/javaapp/HelloWorld)
[Done] exited with code=1 in 0.908 seconds
```
**Expected behavior**
Description of what you expected to happen.
` /usr/bin/env /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home/bin/java -XX:+ShowCodeDetailsInExceptionMessages -cp /Users/sri/Library/Application\ Support/Code/User/workspaceStorage/a7914bcef1b1f13f62c5f39661852924/redhat.java/jdt_ws/JavaWithPackage_faceaf5f/bin com.coderunner.javaapp.HelloWorld
/Users/sri/.zshrc:133: command not found: ng
/Users/sri/Downloads/JavaWithPackage $ /usr/bin/env /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home/bin/java -XX:+ShowCodeDetailsInExceptionMessages -cp /Users/sri/Librar
y/Application\ Support/Code/User/workspaceStorage/a7914bcef1b1f13f62c5f39661852924/redhat.java/jdt_ws/JavaWithPackage_faceaf5f/bin com.coderunner.javaapp.HelloWorld
Hello Code Runner!
/Users/sri/Downloads/JavaWithPackage $
`
**Screenshots**
If applicable, add screenshots to help explain your problem.

Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with the packaged HelloWorld example and inspect the Code Runner Java execution command shown in the issue. Compare the generated classpath and main-class name with the expected com.coderunner.javaapp.HelloWorld invocation; done when running the package example prints Hello Code Runner! without the NoClassDefFoundError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, typescript
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100