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

JavaFX not imported #276

Closed
nihiluis opened this issue Aug 10, 2017 · 7 comments
Closed

JavaFX not imported #276

nihiluis opened this issue Aug 10, 2017 · 7 comments

Comments

@nihiluis
Copy link

nihiluis commented Aug 10, 2017

I'm using gradle. Gradle build works fine. JavaFX classes are not recognized though. My java.home is correctly set and the same as in IntelliJ IDEA. Do I have to add some external JFX library somehow?

Environment
  • Operating System: arch linux
  • JDK version: Oracle
  • Visual Studio Code version: newest
  • Java extension version: newest
buildscript {
    dependencies {
        classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.8.2'
    }
    repositories {
        mavenLocal()
        mavenCentral()
    }
}

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
}

sourceSets {
    main.java.srcDirs = ['src']
    main.resources.srcDirs = ['resources']
}

apply plugin: 'javafx-gradle-plugin'

jfx {
    mainClass = 'x.Main'
    vendor = 'HI'
}

task fatJar(type: Jar) {
    manifest {
        attributes 'Implementation-Title': 'X',
                'Implementation-Version': version,
                'Main-Class': 'x.Main'
    }
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}
@fbricon
Copy link
Collaborator

fbricon commented Aug 10, 2017

Have you tried with Eclipse/Buildship?

@fbricon
Copy link
Collaborator

fbricon commented Aug 10, 2017

Do you have a sample project to reproduce this issue?

@nihiluis
Copy link
Author

I didn't try Eclipse/Buildship. This is my project: https://github.com/nihiluis/jfx-test-boilerplate

@fbricon
Copy link
Collaborator

fbricon commented Aug 24, 2017

So, Java FX is not guaranteed to be present in all JDK distributions, that means your project might not build/work against other JDKs.

For now, your best bet is to tell vscode-java/eclipse.jdt.ls to ignore the error, if you're confident it won't be an issue. In order to do that, you can add a .settings/org.eclipse.jdt.core.prefs file at the root of your project, containing the line:

org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore

@fbricon
Copy link
Collaborator

fbricon commented Aug 24, 2017

Closing as duplicate of #120.

@fbricon fbricon closed this as completed Aug 24, 2017
@nihiluis
Copy link
Author

I got the JDK defined as Oracle in both IntelliJ IDEA and VSCode. I think Oracle distributes JFX. I'll check again eventually.

These warnings don't appear for me. IIRC errors appear, because JFX classes cannot be found. I don't know if both issues are related.

@tomsontom
Copy link

In future (with jdk 11) JavaFX will be shipped as library available from maven central! No JDK will bring by default

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

No branches or pull requests

3 participants