Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Could not find or load main class HelloWorld Caused by: java.lang.NoClassDefFoundError: HelloWorld (wrong name: com/coderunner/javaapp/HelloWorld) #1129

Open
srinivasaraogurram opened this issue Apr 18, 2024 · 0 comments

Comments

@srinivasaraogurram
Copy link

  • 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

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.
![image](https://github.com/formulahendry/vscode-code-runner/assets/2825912/63ecc4ea-8120-450d-ae07-371c592b24dd)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant