Skip to content

Feature request: Provide a way to specify -source and -target for javac with VScode #982

Closed

Description

@marvingreenberg

[provide a description of the issue]

Environment
  • Operating System: MacOS,
  • JDK version: Java 11
  • Visual Studio Code version: Version 1.35.1 (1.35.1)
  • Java extension version: Language Support for Java(tm) 0.46.0
Steps To Reproduce

Allow VScode to build a project. JDK11 is installed and found on path, and is used for builds. Classes generated have class target 55.0
I want to have them generated with target version 52.0 (Java 1.8)

That is, I'd like to be able to pass -source and/or -target to the invocation of javac (or logical equivalent) Could not find any setting or configuration or documentation.

Activity

  1. fbricon commented on Jul 12, 2019

    @fbricon
    Collaborator

    Your best best for now is to use Maven or Gradle to define source/target

  2. marvingreenberg commented on Jul 12, 2019

    @marvingreenberg
    Author

    Unfortunately we're not using those - a custom build system based on ANT. Builds using "our" build system are correctly setting -source,-target but when VScode compiles the files (because of changes) they get generated with an inconsistent target version. Do you know an appropriate setting in the "eclipse" .classpath or .project? We are generating those so that vscode understands our dependencies and such.

  3. changed the title [-]Question: Is there a way to specify -source and -target for javac with VScode[/-] [+]Feature request: Provide a way to specify -source and -target for javac with VScode[/+] on Jul 12, 2019
  4. marvingreenberg commented on Jul 12, 2019

    @marvingreenberg
    Author

    I changed this to a feature request, since that seems reasonable.

  5. fbricon commented on Jul 12, 2019

    @fbricon
    Collaborator

    In that case you need to generate .settings/org.eclipse.jdt.core.prefs files containing

    eclipse.preferences.version=1
    org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
    org.eclipse.jdt.core.compiler.compliance=1.8
    org.eclipse.jdt.core.compiler.source=1.8
    org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
    org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
    org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
    org.eclipse.jdt.core.compiler.processAnnotations=disabled
    org.eclipse.jdt.core.compiler.release=enabled
    
  6. robstryker commented on Nov 2, 2026

    @robstryker
    Contributor

    Approved methods to set source and target versions is to either use maven, gradle, or to add a .settings/org.eclipse.jdt.core.prefs file to your project to let them know your desired settings.

    closing the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions