This same Java class will compile from the command line, but not from NetBeans. Here is the .java file contents:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ripplesoftware.sitereviewer;
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.core.QTextCodec;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QMainWindow;
import com.trolltech.qt.gui.QVBoxLayout;
import com.trolltech.qt.gui.QWidget;
import com.trolltech.qt.gui.QPushButton;
import com.trolltech.qt.gui.QTabWidget;
/**
*
* @author development
*/
public class siteReviewer {
public static void main(String[] args){
QApplication.initialize(args);
QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8"));
QTextCodec.setCodecForLocale(QTextCodec.codecForName("UTF-8"));
QMainWindow mainWindow = new QMainWindow();
/* Set main window */
mainWindow.setWindowTitle("RSC Site Reviewer");
mainWindow.setFixedSize(600,800);
mainWindow.setVisible(true);
/* Set Layout */
QVBoxLayout vBoxLayout = new QVBoxLayout();
vBoxLayout.setContentsMargins(0, 0, 0, 0);
QWidget mainWidget = new QWidget();
mainWidget.setFixedSize(600,800);
mainWidget.setVisible(true);
mainWidget.setLayout(vBoxLayout);
mainWindow.setCentralWidget(mainWidget);
/* */
/* Setup tab */
QTabWidget tabWidget = new QTabWidget(mainWidget);
tabWidget.setDocumentMode(false);
QWidget tab = new QWidget();
tabWidget.addTab(tab, "Tab 1 with lots of words");
QWidget tab2 = new QWidget();
tabWidget.addTab(tab2, "Tab 2");
QPushButton hello = new QPushButton("Quit");
hello.resize(120, 40);
hello.show();
vBoxLayout.addWidget(hello);
QApplication.execStatic();
}
}
Here is how I compile from command line:
$ javac -cp qtjambi-4.8.6.jar:qtjambi-native-macosx-gcc-4.8.6.jar siteReviewer.java
$ java -XstartOnFirstThread -cp qtjambi-4.8.6.jar:qtjambi-native-macosx-gcc-4.8.6.jar siteReviewer.java
Works fine and windows pops up with expected components.
However, when compiling same code with NetBeans Maven Project:
--- exec-maven-plugin:3.0.0:exec (default-cli) @ SiteReviewer ---
Error: Unable to initialize main class com.ripplesoftware.sitereviewer.siteReviewerApp
Caused by: java.lang.NoClassDefFoundError: com/trolltech/qt/gui/QLayout
Command execution failed.
Here is the pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ripplesoftware</groupId>
<artifactId>SiteReviewer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.trolltech.qt</groupId>
<artifactId>qtjambi</artifactId>
<version>4.8.6</version>
<scope>system</scope>
<systemPath>/Users/${USER}/.m2/dependencies/qtjambi-4.8.6.jar</systemPath>
</dependency>
<dependency>
<groupId>com.trolltech.qt</groupId>
<artifactId>qtjambi-native-macosx-gcc</artifactId>
<version>4.8.6</version>
<scope>system</scope>
<systemPath>/Users/${USER}/.m2/dependencies/qtjambi-native-macosx-gcc-4.8.6.jar</systemPath>
</dependency>
</dependencies>
</project>
I'm confused because I'm not calling a class QLayout
, and the code compiles fine from command line. I believe the import statements are OK, because it was preivously complaining about the import com.trolltech.qt
was not found.