user4391669
user4391669

Reputation:

How to fix the "main class not found" error if classpath is set?

I have the following Java application structure:

I build the application with NetBeans on Windows. When launching on Windows the applications starts perfectly. The same applies to launching the jar on Windows.

When copying the jar to Ubuntu Mate on my Raspberry Pi 2 (Oracle JDK 8 for ARM32 v7) I cannot launch the jar with java -jar GoodManagement.jar. It tells me the main class could not be found or loaded.

I tried the following and was not successful:

  1. Setting the CLASSPATH variable ($CLASSPATH) with export CLASSPATH=., CLASSPATH=.:[PATH TO CLASSES FOLDER].
  2. Setting the classpath with -cp or -classpath like above.
  3. Use the absolute path to the jar file as -classpath.
  4. Use the path to the classes folder (like in 1.) and then use the fully qualified class name (goodmanagement.GoodManagementLauncher)

So what can I do to launch my application on Ubuntu?

EDIT1: The output for building the application:

ant -f D:\\Documents\\Fachschaft\\GoodManagement\\GoodManagement jfx-rebuild
init:
deps-clean:
Updating property file: D:\Documents\Fachschaft\GoodManagement\GoodManagement\build\built-clean.properties
Deleting directory D:\Documents\Fachschaft\GoodManagement\GoodManagement\build
clean:
init:
deps-jar:
Created dir: D:\Documents\Fachschaft\GoodManagement\GoodManagement\build
Updating property file: D:\Documents\Fachschaft\GoodManagement\GoodManagement\build\built-jar.properties
Created dir: D:\Documents\Fachschaft\GoodManagement\GoodManagement\build\classes
Created dir: D:\Documents\Fachschaft\GoodManagement\GoodManagement\build\empty
Created dir: D:\Documents\Fachschaft\GoodManagement\GoodManagement\build\generated-sources\ap-source-output
Compiling 39 source files to D:\Documents\Fachschaft\GoodManagement\GoodManagement\build\classes
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Copying 12 files to D:\Documents\Fachschaft\GoodManagement\GoodManagement\build\classes
compile:
Created dir: D:\Documents\Fachschaft\GoodManagement\GoodManagement\dist
Detected JavaFX Ant API version 1.3
Launching <fx:jar> task from C:\Program Files\Java\jdk1.8.0_51\jre\..\lib\ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Launching <fx:deploy> task from C:\Program Files\Java\jdk1.8.0_51\jre\..\lib\ant-javafx.jar
jfx-deployment-script:
jfx-deployment:
jar:
jfx-rebuild:
BUILD SUCCESSFUL (total time: 6 seconds)

And now the manifest file:

Manifest-Version: 1.0
Implementation-Title: GoodManagement
Implementation-Version: 1.0
Permissions: sandbox
Codebase: *
JavaFX-Version: 8.0
Class-Path: 
Created-By: JavaFX Packager
Implementation-Vendor: Daniel
Main-Class: goodmanagement.GoodManagementLauncher

Upvotes: 0

Views: 1615

Answers (1)

user4391669
user4391669

Reputation:

The problem was that I was trying to run a JavaFX application in a VM that has no JavaFX support (arm32 jdk1.8.60). When trying to compile the source code I discovered that the compiler was unable to find the JavaFX classes.

Upvotes: 1

Related Questions