У меня есть Java-программа, которая включает в себя org.eclipse.swt
библиотеки, такие как «Дисплей» и «Оболочка»
Первое, что делает эта программа:
private void authenticationFlow() {
Display display = new Display();
Shell shell = new Shell(display);
final Browser browser;
//some other code here
}
Я экспортировалэта программа в исполняемый файл JAR и может нормально запускать ее на моем ПК.
Однако, при попытке запустить ее на ПК без установленного Eclipse, Программа не запускается.Без исключений.Он просто завершает работу и не запускает остальную часть кода.
Я попытался отладить, создав несколько блоков предупреждений, таких как:
private void authenticationFlow() {
popAlertBox(AlertType.INFORMATION, "Nice", "Something happened", "Starting auth");
Display display = null;
try {
display = new Display();
} catch (Exception e) {
popAlertBox(AlertType.ERROR, "Oh oh", "Something went wrong", e.getMessage());
}
popAlertBox(AlertType.INFORMATION, "Nice", "Something happened", "created display");
Shell shell = new Shell(display);
popAlertBox(AlertType.INFORMATION, "Nice", "Something happened", "created shell");
final Browser browser;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
try {
shell.setLayout(gridLayout);
} catch (Exception e) {
popAlertBox(AlertType.ERROR, "Shell error", "Could not instantiate Shell: ", e.getMessage());
}
//rest of code
И
private void popAlertBox(AlertType type, String title, String header, String contentText) {
Alert alert = new Alert(type);
alert.setTitle(title);
alert.setHeaderText(header);
alert.setContentText(contentText);
alert.setX(GUIMain.getStageX() + GUIMain.getWidth()*0.4);
alert.setY(GUIMain.getStageY()+ GUIMain.getHeight()*0.4);
alert.showAndWait();
}
В итоге я вижу AlertBox "Starting auth", и все, программа завершается сразу после.Я никогда не доходил до «созданного дисплея» AlertBox.
Так что я решил, что это связано с самим SWT.
Теперь мой вопрос
1. Is this really directly related to SWT or am I misunderstanding something.
2. If it is, how can I have this program run on a PC without eclipse installed?
РЕДАКТИРОВАТЬ:
Я использую maven для всех зависимостей. Вот изображение моих библиотек, включая swt
Я попытался окружить свой метод, который вызывается в try catch, вот так:
try{
authenticationFlow();
}catch (Exception e) {
popAlertBox(AlertType.ERROR, "oh oh", "Something went wrong", e.getMessage());
}
popAlertBox(AlertType.INFORMATION, "Nice", "Something happened", "If you see this then something is in fact happening. final popup");
И ни одно из этих двух всплывающих окон не отображается.Не тот, что внутри блока catch, а тот, что потом ни.
Я добавил следующие зависимости в моем файле pom.xml:
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>swt</artifactId>
<version>3.3.0-v3346</version>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>4.3</version>
</dependency>
, и он все еще не работает на ПК, что делаетне установлено затмение