I'm trying to create javafx media player as gradle project, but got this error.error: package javafx.scene.media does not exist on line: import javafx.scene.media.Media;
Here is my build.gradle
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
group 'life.antonov'
version '1.0'
mainClassName='life.antonov.muza.Main'
sourceCompatibility = 11
jar {
manifest {
attributes "Main-Class": "$mainClassName"
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
javafx {
version = "13"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.openjfx', name: 'javafx-controls', version: '13'
compile group: 'org.openjfx', name: 'javafx-fxml', version: '13 '
compile group: 'org.openjfx', name: 'javafx-media', version: '13'
}
I'm tried to unzip downloaded javafx-media jar file and it is almost empty:
$ unzip javafx-media-13.jar
Archive: javafx-media-13.jar
creating: META-INF/
inflating: META-INF/MANIFEST.MF
Why?
Maybe I wrote wrong dependencies?
What I have to do to make my application compile and work?
I have not tested it, but:
Replace:
modules = [ 'javafx.controls', 'javafx.fxml' ]
With
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.media' ]
If you want to use MediaView control in javafx you must to do 2 steps
Step1: add requires javafx.media;
module com.codegym.videoplayerfx {
requires javafx.controls;
requires javafx.fxml;
requires javafx.media; // You must add this line
opens com.codegym.videoplayerfx to javafx.fxml;
exports com.codegym.videoplayerfx;
}
Step2: Add dependency in pom.xml for maven (or build.gradle for gradle). After that you must press build. Try orther dependency version if does't work
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>16</version>
</dependency>
Related
Hello ladies and gentlemen,
so i was just trying to get a executable for my Spring application by using Spring Native.
My build.gradle:
plugins {
id 'org.springframework.boot' version '2.5.4'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'org.springframework.experimental.aot' version '0.10.3'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.4'
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4'
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.4'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.14'
implementation group: 'org.apache.poi', name: 'poi', version: '4.1.2'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.14.6'
implementation group: 'org.json', name: 'json', version: '20180813'
}
test {
useJUnitPlatform()
}
and my settings.gradle:
rootProject.name = 'demo'
after adding the 'org.springframework.experimental.aot' version '0.10.3' plugin to the build.gradle as seen above (doing whats told in the documentary under 2.1.2 https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/#getting-started), i get following error:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.springframework.experimental.aot', version: '0.10.3'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.experimental.aot:org.springframework.experimental.aot.gradle.plugin:0.10.3')
Searched in the following repositories:
Gradle Central Plugin Repository
The person who commented is right, though I think unnecessarily rude given that the tutorial is out of order, and they tell you to apply the plugin prior to giving you instructions how to install.
More specifically, you need to add the spring release maven repo to your settings.gradle.kts in order to source the plugin
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = uri("https://repo.spring.io/release") }
mavenLocal()
}
}
and then also add the repository to your build.gradle.kts in order to source the dependencies
repositories {
maven { url = uri("https://repo.spring.io/release") }
}
I am trying to build fat jar, but the jar is giving me error. I have built fat jar before with javaFx 11 and java 11. Now I am using Java 8 and Spring I am doing it with intellij from File>Project Structure>Artifacts, there I choose ProjectRoot main module and then also add my resources directory content and I build the jar.
[main] DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.boo t.enableautoconfiguration' in any property source
21:31:42.635
[main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:450)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:160)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:96)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:386)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:828)
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:563)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:91)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at com.tick42.QuicksilverApplication.main(QuicksilverApplication.java:13)
My project is:
>ProjectRoot
>src
>main
>resources
>java
>com
>projectId
>restaurant
RestaurantApplication.class
In restaurant folder are all my config and project classes.
My gradle build is at the project root:
buildscript {
ext {
springBootVersion = '2.0.4.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
group = 'com.projectId'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-security")
testCompile('org.springframework.boot:spring-boot-starter-test')
compile group: 'org.springframework.security', name: 'spring-security-jwt', version: '1.0.2.RELEASE'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.6.0'
compile group: 'com.mchange', name: 'c3p0', version: '0.9.5.2'
compile group: 'org.springframework', name: 'spring-jdbc', version: '5.0.8.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: '5.3.5.Final'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
compile group: 'com.googlecode.log4jdbc', name: 'log4jdbc', version: '1.2'
compile "org.springframework.boot:spring-boot-configuration-processor"
compile 'org.passay:passay:1.3.1'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'org.kohsuke', name: 'github-api', version: '1.93'
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
check.dependsOn jacocoTestReport
settings.gradle:
rootProject.name = 'server-side'
My RestaurantAplication.class is was in my restaurant folder, but I read somewhere that it should be above my package with my classes, so I moved it to the projectId folder, but it didn't work.
My main:
#SpringBootApplication
#EnableScheduling
#EnableConfigurationProperties
public class RestaurantApplication {
public static void main(String[] args) {
SpringApplication.run(RestaurantApplication.class, args);
}
}
Edit: in the jars's spring.factories in the META-INF folder there is only one line:
org.springframework.beans.BeanInfoFactory=org.springframework.beans.ExtendedBeanInfoFactory
I tried adding them to the file also adding some of the ones listed in the error and also my config files:
org.springframework.beans.BeanInfoFactory=org.springframework.beans.ExtendedBeanInfoFactory
org.springframework.boot.autoconfigure.AutoConfigurationImportSelector
org.springframework.context.annotation.ConfigurationClassParser
com.projectId.restaurant.config.AppConfig
com.projectId.restaurant.config.PasswordEncoderConfig
com.projectId.restaurant.config.ScheduleConfig
com.projectId.restaurant.config.Scheduler
com.projectId.restaurant.config.SecurityConfig
But even then the lines in the error still exist for the exact configurations I have added:
...
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:160)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:96)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:386)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:828)
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:563)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
...
I am using STS.
This is my main class:
#EnableZuulProxy
#SpringBootApplication
public static void main(String[] args) {
try {
SpringApplication.run(DevProxyApp.class, args);
}catch(Exception e) {
}
}
}
Below is my build.gradle :
buildscript {
ext {
springBootVersion = '2.0.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'pmd'
id 'org.sonarqube' version '2.6.2'
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
mainClassName = 'com.siemens.mindsphere.devproxy.DevProxyApp'
group = 'mindsphere'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
ext {
springCloudVersion = 'Finchley.BUILD-SNAPSHOT'
}
jar {
baseName = 'sdk-devproxy'
doLast {
}
destinationDir = file("$buildDir/libs/mindsphere/sdk-devproxy/$project.version/")
}
dependencies {
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-parent', version: 'Edgware.SR3', ext: 'pom'
compile('org.springframework.cloud:spring-cloud-starter-oauth2')
compile('org.springframework.cloud:spring-cloud-starter-netflix-zuul')
compile('org.springframework.boot:spring-boot-starter-web')
compile group: 'com.auth0', name: 'java-jwt', version: '3.3.0'
compile('com.auth0:java-jwt')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
i have also tried with below dependencies:
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '1.2.1.RELEASE', ext: 'pom'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-parent', version: 'Edgware.SR3', ext: 'pom'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-oauth2', version: '1.0.0.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zuul', version: '1.4.4.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.9.RELEASE'
implementation 'org.slf4j:slf4j-api:1.7.25'
compile group: 'com.auth0', name: 'java-jwt', version: '3.3.0'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
}
Whenever I run the application as spring boot app its giving me the below error:
Error: Could not find or load main class com.siemens.mindsphere.devproxy.DevProxyApp
While running as java application, it is working starting but with this kind of launch functionalities(oauth2, zuul routing functionalities) are not working.
i have tried below things, but still issue is there:
Refreshing , rebuilding, updating gradle
removing all the dependencies manually, removing gradle repo manually
installed new STS.
If you need any other info to address this issue please let me know.
FYI Previously it was a maven project and working fine, now I am making it as gradle project by adding build.gradle, gradle project and etc. and removed pom.xml. Gradle build is happening properly.
Is the issue with any jar compatibility ????
Try to add a manifest attribute:
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'com.siemens.mindsphere.devproxy.DevProxyApp'
)
}
}
Try to downgrade the springBootVersion.
I had this issue and this resolved it.
I would like to embed dependency information into my manifest file, so that I can expose this information at runtime. i.e. I can see which version of a library is used by a particular running instance of my service.
I'm using gradle to build my 'fatjar':
shadowJar {
mergeServiceFiles()
archiveName "service.jar"
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
manifest {
attributes('Main-Class': "service.Service",
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Implementation-Version': version,
'Implementation-Title': project.name)
}
}
And I have dependencies on various other libraries:
dependencies {
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.39'
...
}
How can I add the dependency information into my manifest file? For example:
Manifest-Version: 1.0
Implementation-Title: service
Implementation-Version: Local Build
Built-By: me
Built-Date: Wed Jun 22 14:13:53 BST 2016
Built-JDK: 1.8.0_91
Main-Class: service.Service
Dependency-mysql-connector-java: mysql:mysql-connector-java:5.1.39
It can be done in the following way:
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.guava:guava:19.0'
compile 'com.google.inject:guice:4.1.0'
}
shadowJar {
mergeServiceFiles()
archiveName "service.jar"
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
manifest {
attributes(
[
'Main-Class': "service.Service",
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Implementation-Version': 'version',
'Implementation-Title': project.name,
] +
project.configurations.compile.allDependencies.collect { d ->
[
("dependency-${d.group.replaceAll('\\.','-')}".toString()):"$d.group:$d.name:$d.version"
]
}.sum()
)
}
}
The script above produces the following MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: service.Service
Built-By: opal
Built-Date: Mon Jul 04 17:27:05 CEST 2016
Built-JDK: 1.8.0_91
Implementation-Version: version
Implementation-Title: 37969253
dependency-com-google-guava: com.google.guava:guava:19.0
dependency-com-google-inject: com.google.inject:guice:4.1.0
Since attributes takes Map as an argument, you need to collect them dependencies, transform them to Map and sum the maps.
This is my first time using Java Web Start. This is for a demo version of my application. I have uploaded the JAR to my server, and created a JNLP file. When I run the file locally, I get the exception shown below.
This was the reference I was reading, and below is my JNLP file.
DerbyPro.jnlp
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
<information>
<title>Derby Pro</title>
<vendor>Neon Orb</vendor>
<icon href="http://neonorb.com/images/derby-pro/derby-pro-icon-hd.png"/>
<offline-allowed/>
</information>
<resources>
<j2se version="1.8+" href=
"http://neonorb.com"/>
<jar href="http://neonorb.com/clientportal/derby-pro-demo.jar"
main="true" />
</resources>
<application-desc
name="Derby Pro"
main-class="com.neonorb.derbypro.main.DerbyPro"
width="300"
height="300">
</application-desc>
<update check="background"/>
</jnlp>
Here is my build.gradle file being called like this: ./gradlew -Pversion=0.0.0 -Pdemo=true fatJar
group 'com.neonorb'
apply plugin: 'java'
sourceCompatibility = 1.8
project.description = 'Derby Pro is pinewood derby management software.'
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Version': version,
'Main-Class': 'com.neonorb.derbypro.main.DerbyPro',
'Demo': demo
}
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
repositories {
mavenCentral()
maven {
url "http://www.sparetimelabs.com/maven2"
}
mavenLocal()
}
dependencies {
compile files('dfalex-0.9.2.jar')
compile 'com.neonorb:commons:+'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.5.4'
compile group: 'commons-cli', name: 'commons-cli', version: '1.3.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.10'
compile group: 'org.fxmisc.easybind', name: 'easybind', version: '1.0.3'
compile group: 'org.scream3r', name: 'jssc', version: '2.8.0'
compile group: 'com.sparetimelabs', name: 'purejavacomm', version: '0.0.28'
compile 'net.java.dev.jna:jna:4.2.1'
compile 'commons-io:commons-io:2.4'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'net.jodah:concurrentunit:0.4.2'
}
//Native launchers
//Windows
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'gradle.plugin.edu.sc.seis.gradle:launch4j:1.6.1'
}
}
apply plugin: 'edu.sc.seis.launch4j'
launch4j {
//outputDir = 'native/windows'
bundledJrePath = 'jre'
dontWrapJar = true
jar = 'bin/derby-pro.jar'
mainClassName = 'com.neonorb.derbypro.main.DerbyPro'
icon = '../../src/main/resources/com/neonorb/derbypro/assets/derby-pro-icon-favicon.ico'
outfile = 'DerbyPro.exe'
companyName = 'Neon Orb'
productName = 'Derby Pro'
}
//OS X
/*plugins {
id "edu.sc.seis.macAppBundle" version "2.1.0"
}
macAppBundle {
mainClassName = "com.example.myApp.Start"
icon = "myIcon.icns"
bundleJRE = true
javaProperties.put("apple.laf.useScreenMenuBar", "true")
backgroundImage = "doc/macbackground.png"
}*/
Here is the manifest directory.
And here is the manifest content.
Manifest-Version: 1.0
Implementation-Version: 0.0.0
Main-Class: com.neonorb.derbypro.main.DerbyPro
Demo: true
Your jar file contains duplicate entries which probably cause problems when being deployed. If you run the following command with your jar file you will see the duplicate entries:
$ unzip -l derby-pro-demo.jar |grep META
0 01-26-16 11:47 META-INF/
116 01-26-16 11:47 META-INF/MANIFEST.MF
321 06-09-15 18:42 META-INF/LICENSE
825 06-09-15 18:42 META-INF/NOTICE
...
11358 06-14-15 12:06 META-INF/LICENSE.txt
172 06-14-15 12:06 META-INF/NOTICE.txt
...
11358 04-03-15 14:30 META-INF/LICENSE.txt
301 04-03-15 14:30 META-INF/NOTICE.txt
The problem is caused by the fatJar. See here and here.
When creating a fat jar, the duplicate entries should be resolved. I have no experience with gradle. The issue (first link) is still marked "open", so I assume there may not be an easy fix. As a work around (if this is possible and works for you), I could imagine to copy all jar content first to a temporary directory. This would overwrite duplicate entries. Then you could build the fat jar from the temporary directory. However, I'd be very careful with that. First some duplicate class files may be relevant, and second the LICENSE, NOTICE, etc. files certainly will cause a license problem.
The JNLP file contains a main class attribute, Java Web Start is trying to create the manifest with that main class. Therefore removing the main class attribute from the JNLP file allows it to run.