This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 256498 - Error: Could not find or load main class Test
Summary: Error: Could not find or load main class Test
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Mixed Development (show other bugs)
Version: 8.1
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: petrk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-10 14:14 UTC by ARESdev
Modified: 2016-09-01 14:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ARESdev 2015-11-10 14:14:50 UTC
Followed the Oracle video tutorial for mixed development.  The procedure sets the Jave app Run property "VM" to  -Djava.library.path=C:/Javafx Test Dev/Native10/dist/Debug/MinGW-Windows

When I RUN the Java app: Error: Could not find or load main class Test displays in the Output window.

If I remove the VM property, the app starts and display a 'running' status until terminated.

Defining System.loadLibrary("libNative10"); or the complete path makes no difference.  The C++ lib builds successfully.

Tried jdk1.8.0_51, 65 and 66
Comment 1 soldatov 2015-11-11 21:32:12 UTC
Did you use 64-bit java? Did you use 64-bit MinGW? Did you use space in path to library?
Comment 2 ARESdev 2015-11-12 13:22:34 UTC
Thanks for your response.  This is the tutorial I am following:
Mixed Java and C/C++ Development 
https://www.youtube.com/watch?v=1vfIcWayWck

Using 64 bit Java - About Info:
Product Version: NetBeans IDE 8.1 (Build 201510222201)
Java: 1.8.0_65; Java HotSpot(TM) 64-Bit Server VM 25.65-b01
Runtime: Java(TM) SE Runtime Environment 1.8.0_65-b17
System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\ax252_000\AppData\Roaming\NetBeans\8.1
Cache directory: C:\Users\ax252_000\AppData\Local\NetBeans\Cache\8.1
Using 64 bit MinGW

Path containing space?:
Yes, the original VM path did contain spaces:
C:\Javafx Test Dev\HelloFX
C:\Javafx Test Dev\Native10\dist\Debug\MinGW-Windows (libNative10.dll)

Came to that same possibility yesterday and changed the base path to:
C:\Javaz\HelloFX\dist (libNative10.dll)
C:\Javaz\Native10\dist\Debug\MinGW-Windows (libNative10.dll)

This change resolved the "Error: Could not find or load main class Test" issue

Started the Java app in Debug set to the System.loadLibrary statement:

  System.loadLibrary("libNative10"); or
  System.loadLibrary("C:\Javafx Test Dev\Native10\dist\Debug\MinGW-Windows\libNative1"); or 
  System.loadLibrary("C:/Javaz/HelloFX/dist/libNative10.dll"); after copying libNative10.dll to the C:/Javaz/HelloFX/dist folder

In each case, Java compiles and begins execution. The status bar is active with a "running" message. After 10 - 20 seconds, the status bar activity stops and the app is hung.

Regards,
Jim
Comment 3 ARESdev 2015-11-12 13:27:37 UTC
Correct to last post:


  System.loadLibrary("C:\Javafx Test Dev\Native10\dist\Debug\MinGW-Windows\libNative1"); or

should be:

  System.loadLibrary("C:\Javaz\Native10\dist\Debug\MinGW-Windows\libNative1"); or
Comment 4 ARESdev 2015-11-19 14:06:19 UTC
*** Update ***
Did some additional testing:
NetBeans 8.1 - C++ TDM-GCC-64

Based on the YouTube tutorial, created a java app and C++ lib. The java app run successfully and showed the results as per the video.

created a JavaFX app and C++ lib. The JavaFX VM property was created correctly by the IDE.  Default JavaFX Hello World application template was used.

The System.loadLibrary and native function call was added to btn action:

btn.setOnAction(new EventHandler<ActionEvent>() {
            
            @Override
            public void handle(ActionEvent event) {
                System.loadLibrary("libHjavaNative");
                new Hjava().NativeGreeting();
                System.out.println("Hello World!");
            }
        });

When the JavaFX app is RUN, the application window displays.  The button is selected and the IDE status bar is active with 'running' text.
After about 8 - 10 seconds, the status bar freezes.

If I select the buttin again, the above scenario repeats.  Hope this helps in the issue research.

Jim