Skip to content

Error: Could not find or load main class @x.y.z.argfile #769

Closed

Description

[provide a description of the issue]

Environment
  • Operating System: MacOS 10.14.6
  • JDK version: 1.8.0_151
  • Visual Studio Code version: 1.42.1
  • Java extension version: Extension Pack 0.8.1
  • Java Debugger extension version: I can't figure out how to determine this: "debugger for Java" doesn't appear in list of installed extension
Steps To Reproduce
  1. [step 1]

  2. [step 2]

The issue is that upon launching a debugger, VS Code runs this command line:

~/Sync/projects/music/music-03:cd /Users/Mike/Sync/projects/music/music-03 ; /Library
/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java
-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:58363
-Dfile.encoding=UTF-8 @/var/folders/pn/3p41p2fj14d50n707c7x2p4c0000gn
/T/cp_90sfb6m3zinsbhwyvyknqb5hv.argfile ptcs.App

And I get this error:
Error: Could not find or load main class
@.var.folders.pn.3p41p2fj14d50n707c7x2p4c0000gn.T.cp_90sfb6m3zinsbhwyvyknqb5hv.argfile

I have no idea where the command line came from... as far as I can tell, it's illegal on Mac to use an "at sign" @ in the command line, and java is trying to interpret that as the main class, so something is wrong.

[attach a sample project reproducing the error]
attach logs

Create Maven project in VS Code... install all Java extensions.

Work with project for several months, making many changes. Not sure what details are significant.

Here's the project:
music-03.zip

Try to launch debugger in maven project, using the default launch.json. I'm not using the "current file" one, but using the (Launch) - App config.

"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Debug (Launch)-App",
"request": "launch",
"mainClass": "ptcs.App",
"projectName": "music-03"
}
]

Current Result
Expected Result
Additional Informations

Activity

  1. testforstephen commented on Mar 2, 2020

    @testforstephen
    Contributor

    @argfile is only supported by java 9 and above, this looks like the debugger uses a wrong approach to shorten the command line.

    There are two workarounds to unblock you first:

    • The first one is to add "shortenCommandLine": "jarmanifest" to your launch.json.

    • The second one is to change your JAVA_HOME environment variable to /Library
      /Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home, and close vscode and reopen it again.

  2. dgh1000 commented on Mar 3, 2020

    @dgh1000
    Author

    Thanks, that works. Would updating my project to Java 11 work as well? I just gave it a try and it that also seems to work without needing your other proposals.

  3. testforstephen commented on Mar 3, 2020

    @testforstephen
    Contributor

    Thanks, that works. Would updating my project to Java 11 work as well? I just gave it a try and it that also seems to work without needing your other proposals.

    CORRECT! You don't need the additional workaround if you update the project to Java 11.

  4. dgh1000 commented on Mar 3, 2020

    @dgh1000
    Author

    Okay you can close this (or should I? not sure how this works)

  5. testforstephen commented on Mar 3, 2020

    @testforstephen
    Contributor

    it still has space to improve in the debugger side, let's keep it open first. i'm trying to deliver some enhancement in the debugger.

  6. testforstephen commented on Mar 4, 2020

    @testforstephen
    Contributor

    User's JAVA_HOME points to JDK 11, his project is Java 8. The debugger will use JDK 8 to launch his application. But the debugger uses a wrong approach @argfile to shorten the command line for the JDK 8.

    Cause:

    Debugger 0.25.0 version adds a fix to choose the project's Java runtime to launch the application instead of the JAVA_HOME. On the other side, when the debugger computes the approach of shortening the command line length, it still uses the JDK from JAVA_HOME to check the compatibility, where it's supposed to use the project's Java runtime as the checker.

  7. changed the title [-]running debugger in Maven project produces command with illegal @ symbol[/-] [+]Error: Could not find or load main class @x.y.z.argfile[/+] on Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions