fxlauncher
fxlauncher copied to clipboard
java.lang.ClassNotFoundException
java.lang.ClassNotFoundException: com.greencoding.MyApp at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at fxlauncher.AbstractLauncher.createApplicationEnvironment(AbstractLauncher.java:161) at fxlauncher.Launcher.lambda$start$0(Launcher.java:149) at java.lang.Thread.run(Thread.java:748)
here is my pom file. it is work fine when your demo project executed. but when I started new project to implement that above exception is throwing when running the application.
<groupId>com.greencoding</groupId>
<artifactId>MyApp</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>MyApp</name>
<dependencies>
<dependency>
<groupId>no.tornado</groupId>
<artifactId>fxlauncher</artifactId>
<version>1.0.16</version>
</dependency>
</dependencies>
<properties>
<!-- Installer Filename without suffix -->
<app.filename>MyApp</app.filename>
<!-- The JavaFX Application class name -->
<app.mainClass>com.greencoding.MyApp</app.mainClass>
<!-- Optional override to specify where the cached files are stored. Default is current working directory -->
<app.cacheDir>USERLIB/MyApp</app.cacheDir>
<!-- Optional parameters to the application, will be embedded in the launcher and can be overriden on the command line -->
<app.parameters>--myOption=myValue --myOtherOption=myOtherValue</app.parameters>
<!-- The Application vendor used by javapackager -->
<app.vendor>Green Coding</app.vendor>
<!-- The Application version used by javapackager -->
<app.version>2.0</app.version>
<!-- Base URL where you will host the application artifacts -->
<app.url>http://demo.example</app.url>
<!-- Optional scp target for application artifacts hosted at the above url -->
<app.deploy.target>[email protected]:demo</app.deploy.target>
<!-- The app and launcher will be assembled in this folder -->
<app.dir>${project.build.directory}/app</app.dir>
<!-- Native installers will be built in this folder -->
<app.installerdir>${project.build.directory}/installer</app.installerdir>
<!-- Should the client downgrade if the server version is older than the local version? -->
<app.acceptDowngrade>false</app.acceptDowngrade>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<organization>
<!-- Used as the 'Vendor' for JNLP generation -->
<name>Green Coding</name>
</organization>
<build>
<plugins>
<!-- Compile project jar to appdir -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<outputDirectory>${app.dir}</outputDirectory>
</configuration>
</plugin>
<!-- Copy dependencies to appdir -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<configuration>
<excludeScope>provided</excludeScope>
<outputDirectory>${app.dir}</outputDirectory>
<stripVersion>true</stripVersion>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<!-- Generate app.xml manifest -->
<executions>
<execution>
<id>create-manifest</id>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>fxlauncher.CreateManifest</mainClass>
<arguments>
<argument>${app.url}</argument>
<argument>${app.mainClass}</argument>
<argument>${app.dir}</argument>
<argument>--cache-dir=${app.cacheDir}</argument>
<argument>--accept-downgrade=${app.acceptDowngrade}</argument>
<argument>--include-extensions=jpg</argument>
<argument>${app.parameters}</argument>
</arguments>
</configuration>
</execution>
<!-- Embed app.xml inside fxlauncher.xml so we don't need to reference app.xml to start the app -->
<execution>
<id>embed-manifest-in-launcher</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>jar</executable>
<workingDirectory>${app.dir}</workingDirectory>
<arguments>
<argument>uf</argument>
<argument>fxlauncher.jar</argument>
<argument>app.xml</argument>
</arguments>
</configuration>
</execution>
<!-- Optional step to include custom UI, see https://github.com/edvin/fxlauncher-custom-ui -->
<!--<execution>-->
<!--<id>embed-custom-ui-in-launcher</id>-->
<!--<phase>package</phase>-->
<!--<goals>-->
<!--<goal>exec</goal>-->
<!--</goals>-->
<!--<configuration>-->
<!--<executable>jar</executable>-->
<!--<workingDirectory>${app.dir}</workingDirectory>-->
<!--<arguments>-->
<!--<argument>uf</argument>-->
<!--<argument>fxlauncher.jar</argument>-->
<!--<argument>-C</argument>-->
<!--<argument>${project.basedir}/../fxlauncher-custom-ui/target/classes</argument>-->
<!--<argument>.</argument>-->
<!--</arguments>-->
<!--</configuration>-->
<!--</execution>-->
<!-- Create native installer. Feel free to add more arguments as needed.
https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javapackager.html
-->
<execution>
<id>installer</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>javapackager</executable>
<arguments>
<argument>-deploy</argument>
<argument>-native</argument>
<argument>-outdir</argument>
<argument>${app.installerdir}</argument>
<argument>-outfile</argument>
<argument>${app.filename}</argument>
<argument>-srcdir</argument>
<argument>${app.dir}</argument>
<argument>-srcfiles</argument>
<argument>fxlauncher.jar</argument>
<argument>-appclass</argument>
<argument>fxlauncher.Launcher</argument>
<argument>-name</argument>
<argument>${project.name}</argument>
<argument>-title</argument>
<argument>${project.name}</argument>
<argument>-vendor</argument>
<argument>${app.vendor}</argument>
<argument>-BappVersion=${app.version}</argument>
<argument>-Bidentifier=${project.groupId}.${project.artifactId}</argument>
</arguments>
</configuration>
</execution>
<!-- Copy application artifacts to remote site using scp (optional) -->
<execution>
<id>deploy-app</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>scp</executable>
<arguments>
<argument>-r</argument>
<argument>target/app/.</argument>
<argument>${app.deploy.target}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
The issue is that you don't have a class called com.greencoding.MyApp
in your target
folder. Double check the class name and inspect the target folder :) If not, can you post a link to your project so I can take a look at the code?
okay, can you specify me where is the target folder is?
Directly in your project folder after you have built the project.
yeah inside the target folder there are 5 folders. This is my testing project link and I'm using NetBeans IDE 8.2 on Windows 10 64bit platform to generate target folder.
https://github.com/HiranManjula/green-myapp
FYI : seems like there is no different between your demo project main class path & my project main class path.
hi edvin, could you please help me to get rid this out?
The reason is simple - the installer is now able to download the files from the url you provided (http://demo.example is not where you're hosting your application artifacts). Since the installer cannot download the application library files, it simply can't run the app. You posted the bottom most error message, but you'll see an error message pertaining to failed HTTP downloads higher up in the log. Before you try to run your app, you need to actually deploy the app files and make sure they are available at the url you specified.