Содержание
- JDK 9 module-info.java handling #75
- Comments
- Syntax error on token «module», module expected» error
- ошибка в файле module-info.java в проекте javafx
- 1 ответ
JDK 9 module-info.java handling #75
Having a module-info.java in the source set leads to unexpected format exceptions starting with
Skip module-info.java although it ends with .java Line Main.java :118 already skips non-Java files. Could easily be handled here.
Support module-info.java syntax and reformat it as well.
The text was updated successfully, but these errors were encountered:
I’d prefer (2), but I’m also not sure what the timeline is for ecj’s java 9 support.
I prefer (2) as well, but (1) could serve as an interim solution, until ECJ supports Java 9.
Latest module syntax with layout example can be found here: http://cr.openjdk.java.net/
Any news on ecj’s java 9 support? The com.google.errorprone:javac:9-dev-r3297-1-shaded does not contain it, I guess.
We migrated from ecj to javac. javac has JDK 9 support, but I’m not sure if the version the formatter is using is new enough.
But it is missing the -shaded suffix: 9-dev-r3297-1-shaded
Although the file size suggests it does include all dependencies. but org.openjdk.tools.javac.**.* types are missing.
Seems like the update of javac would solve this problem, if -source 9 could be specified:
I added initial support for this in c31bb19. If anyone’s interested in trying it out, please report any issues you find — we don’t have a huge corpus of module-info s to test against yet.
I’ll cut a new release soon that includes that change unless any issues turn up.
All branches of the JLS module production are hit by the example M1 input/output pair:
I’ll cut a new release soon that includes that change unless any issues turn up.
Great news! (With tiny chance seeing #106 included as well?)
Also all 30 module-info.java files in https://github.com/AdoptOpenJDK/jdk9-jigsaw were formatted successfully.
Generated patch looks ok
While running against all 350 module descriptors found in an OpenJDK mirror, I found something in openjdk-jdk9langtoolstestjdkjavadocdoclettestModulesmoduletagsmodule-info.java :
Looks a like file to test the «(one of)» rule from the requires production.
Here is the error message, with some more invalid(?) module files:
Источник
Syntax error on token «module», module expected» error
Welcome to CodeRanch!
The file needs to be named module-info.java.
Stephan van Hulst wrote: Welcome to CodeRanch!
The file needs to be named module-info.java.
Welcome to CodeRanch!
module-info.java
Looks like this
module trigger
<
requires java.desktop;
requires java.sql;
>
I am using jdk 1.8 version
I am building small program using java swing.
Please help me I am facing issue
Syntax error or token «module», interface expected.
The project cannot be built untill build path errors resolved
Источник
ошибка в файле module-info.java в проекте javafx
Я уже некоторое время использую javaFX, но день назад, когда я создал новый проект, я заметил, что в пакете по умолчанию автоматически создается новый файл с именем (module-info.java), и я даже не могу удалите это.
Там написан следующий код:
К сожалению, во всех строках есть ошибки
1-я строка: Синтаксическая ошибка токена «модуль», ожидается интерфейс
2-я строка: Синтаксическая ошибка токена «.», Ожидается
3-я строка: ** Несколько маркеров в этой строке
1 ответ
Файл module-info.java выглядит довольно типично для модульных проектов Java (Java 9+). Обычно требуется javafx.controls и открыть ваше приложение (здесь фактически названное «application») для javafx. Я думаю, что это последнее утверждение относится к модулю javafx, который должен иметь возможность заглядывать в модуль, который имеет точку входа для программы.
Но расположение файла мне кажется подозрительным. Я не разбираюсь во всех сложностях, но я думаю, что файл лучше разместить непосредственно в каталоге / src, а не в пакете по умолчанию. Обычно файл module-info.java является верхним уровнем папки файлов, а исходный код программы — дочерней папкой.
Другими словами, файл module-info.java и файл пакета / application должны находиться в одной папке. По крайней мере, так все устроено в моих программах javafx и модульных программах Java.
РЕДАКТИРОВАТЬ: я заметил, что в вашем пути сборки указан Java 1.5! Эта Java не поддерживает модули. Модули были введены в Java 9.
Источник
Index: session-2-jlink/02_JMod/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-2-jlink/02_JMod/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-2-jlink/02_JMod/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-2-jlink/01_JLink/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-2-jlink/01_JLink/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-2-jlink/01_JLink/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-2-jlink/02_JMod/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-2-jlink/02_JMod/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-2-jlink/02_JMod/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ requires org.astro;
+}
Index: session-2-jlink/01_JLink/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-2-jlink/01_JLink/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-2-jlink/01_JLink/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ requires org.astro;
+}
Index: session-1-jigsaw-intro/06_Services/src/com.socket/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/06_Services/src/com.socket/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/06_Services/src/com.socket/module-info.java (revision )
@@ -1,5 +1,6 @@
module com.socket {
- exports com.socket;
- exports com.socket.spi;
- uses com.socket.spi.NetworkSocketProvider;
-}
No newline at end of file
+ exports com.socket;
+ exports com.socket.spi;
+
+ uses com.socket.spi.NetworkSocketProvider;
+}
Index: session-1-jigsaw-intro/04_Packaging/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/04_Packaging/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/04_Packaging/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-1-jigsaw-intro/06_Services/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/06_Services/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/06_Services/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
module com.greetings {
- requires com.socket;
-}
No newline at end of file
+ requires com.socket;
+}
Index: session-1-jigsaw-intro/04_Packaging/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/04_Packaging/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/04_Packaging/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ requires org.astro;
+}
Index: session-1-jigsaw-intro/01_Greetings/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/01_Greetings/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/01_Greetings/src/com.greetings/module-info.java (revision )
@@ -1,1 +1,1 @@
-module com.greetings { }
No newline at end of file
+module com.greetings {}
Index: session-1-jigsaw-intro/06_Services/src/org.fastsocket/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/06_Services/src/org.fastsocket/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/06_Services/src/org.fastsocket/module-info.java (revision )
@@ -1,5 +1,6 @@
module org.fastsocket {
- requires com.socket;
- provides com.socket.spi.NetworkSocketProvider
- with org.fastsocket.FastNetworkSocketProvider;
-}
No newline at end of file
+ requires com.socket;
+
+ provides com.socket.spi.NetworkSocketProvider with
+ org.fastsocket.FastNetworkSocketProvider;
+}
Index: session-1-jigsaw-intro/02_GreetingsWorld/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/02_GreetingsWorld/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/02_GreetingsWorld/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-1-jigsaw-intro/09_Automodules/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/09_Automodules/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/09_Automodules/src/com.greetings/module-info.java (revision )
@@ -1,4 +1,6 @@
module com.greetings {
- requires junit;
- exports com.greetings to junit;
-}
No newline at end of file
+ requires junit;
+
+ exports com.greetings to
+ junit;
+}
Index: session-1-jigsaw-intro/05_Missing_exports/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/05_Missing_exports/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/05_Missing_exports/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- // exports org.astro;
-}
No newline at end of file
+module org.astro {
+ // exports org.astro;
+}
Index: session-1-jigsaw-intro/05_Missing_requires/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/05_Missing_requires/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/05_Missing_requires/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-1-jigsaw-intro/02_GreetingsWorld/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/02_GreetingsWorld/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/02_GreetingsWorld/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ requires org.astro;
+}
Index: session-1-jigsaw-intro/05_Missing_exports/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/05_Missing_exports/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/05_Missing_exports/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ requires org.astro;
+}
Index: session-1-jigsaw-intro/05_Missing_requires/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/05_Missing_requires/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/05_Missing_requires/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- // requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ // requires org.astro;
+}
Index: session-1-jigsaw-intro/08_ModulesExportConflict/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/08_ModulesExportConflict/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/08_ModulesExportConflict/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-1-jigsaw-intro/03_MultiModuleCompilation/src/org.astro/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/03_MultiModuleCompilation/src/org.astro/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/03_MultiModuleCompilation/src/org.astro/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-1-jigsaw-intro/08_ModulesExportConflict/src/org.astro2/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/08_ModulesExportConflict/src/org.astro2/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/08_ModulesExportConflict/src/org.astro2/module-info.java (revision )
@@ -1,3 +1,3 @@
-module org.astro {
- exports org.astro;
-}
No newline at end of file
+module org.astro {
+ exports org.astro;
+}
Index: session-1-jigsaw-intro/07_patch_module_option/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/07_patch_module_option/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/07_patch_module_option/src/com.greetings/module-info.java (revision )
@@ -1,2 +1,1 @@
-module com.greetings {
-}
No newline at end of file
+module com.greetings {}
Index: session-1-jigsaw-intro/08_ModulesExportConflict/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/08_ModulesExportConflict/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/08_ModulesExportConflict/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ requires org.astro;
+}
Index: session-1-jigsaw-intro/03_MultiModuleCompilation/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/03_MultiModuleCompilation/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/03_MultiModuleCompilation/src/com.greetings/module-info.java (revision )
@@ -1,3 +1,3 @@
-module com.greetings {
- requires org.astro;
-}
No newline at end of file
+module com.greetings {
+ requires org.astro;
+}
Index: session-1-jigsaw-intro/07_patch_ConcurrentHashMap/src/com.greetings/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-1-jigsaw-intro/07_patch_ConcurrentHashMap/src/com.greetings/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-1-jigsaw-intro/07_patch_ConcurrentHashMap/src/com.greetings/module-info.java (revision )
@@ -1,2 +1,1 @@
-module com.greetings {
-}
No newline at end of file
+module com.greetings {}
Index: session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.rest/src/main/java/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.rest/src/main/java/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.rest/src/main/java/module-info.java (revision )
@@ -1,13 +1,11 @@
module monitor.rest {
- requires java.xml.bind;
- requires java.xml.ws.annotation;
-
- requires monitor.utils;
- requires monitor.statistics;
-
- requires spark.core;
- requires jackson.core;
- requires jackson.databind;
+ requires java.xml.bind;
+ requires java.xml.ws.annotation;
+ requires monitor.utils;
+ requires monitor.statistics;
+ requires spark.core;
+ requires jackson.core;
+ requires jackson.databind;
- exports monitor.rest;
+ exports monitor.rest;
}
Index: session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.utils/src/main/java/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.utils/src/main/java/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.utils/src/main/java/module-info.java (revision )
@@ -1,4 +1,4 @@
module monitor.utils {
- // requires
- exports monitor.utils;
+ // requires
+ exports monitor.utils;
}
Index: session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer/src/main/java/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer/src/main/java/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer/src/main/java/module-info.java (revision )
@@ -1,3 +1,3 @@
module monitor.observer {
- exports monitor.observer;
+ exports monitor.observer;
}
Index: session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.statistics/src/main/java/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.statistics/src/main/java/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.statistics/src/main/java/module-info.java (revision )
@@ -1,4 +1,5 @@
module monitor.statistics {
- requires monitor.observer;
- exports monitor.statistics;
+ requires monitor.observer;
+
+ exports monitor.statistics;
}
Index: session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer.beta/src/main/java/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer.beta/src/main/java/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer.beta/src/main/java/module-info.java (revision )
@@ -1,4 +1,5 @@
module monitor.observer.beta {
- requires monitor.observer;
- exports monitor.observer.beta;
+ requires monitor.observer;
+
+ exports monitor.observer.beta;
}
Index: session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer.alpha/src/main/java/module-info.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer.alpha/src/main/java/module-info.java (revision 46cb9e190b44d0d8aa4f2f4544ebc41251939c52)
+++ session-3-refactoring-migration/04_ServiceMonitor_modularisation_to_java_9/monitor.observer.alpha/src/main/java/module-info.java (revision )
@@ -1,4 +1,5 @@
module monitor.observer.alpha {
- requires monitor.observer;
- exports monitor.observer.alpha;
+ requires monitor.observer;
+
+ exports monitor.observer.alpha;
}
posted 2 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Can anyone teach me how to resolve «Syntax error on token «module», module expected» error?
Java used is already jdk13.0.1 yet my eclipse is unable to resolve the «module» keyword in package-info.java.
Question1.PNG
Saloon Keeper
Posts: 14713
posted 2 years ago
-
1
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Welcome to CodeRanch!
The file needs to be named
module-info.java
.
Darack Chowansky
Greenhorn
Posts: 10
posted 2 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Stephan van Hulst wrote:Welcome to CodeRanch!
The file needs to be named
module-info.java
.
Thank you!
Sorry for such an elementary mistake.
Marshal
Posts: 77299
posted 2 years ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
There is no need to be sorry.
posted 1 year ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
My file name is module-info.java. still I have this error
Stephan van Hulst
Saloon Keeper
Posts: 14713
posted 1 year ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Welcome to CodeRanch!
Tejaswini Halakate
Greenhorn
Posts: 2
posted 1 year ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
module-info.java
Looks like this
module trigger
{
requires java.desktop;
requires java.sql;
}
I am using jdk 1.8 version
I am building small program using java swing.
Please help me I am facing issue
Syntax error or token «module», interface expected.
The project cannot be built untill build path errors resolved
Stephan van Hulst
Saloon Keeper
Posts: 14713
posted 1 year ago
-
-
Number of slices to send:
Optional ‘thank-you’ note:
-
-
Modules were added in Java 9. You need to update your JDK. I recommend you use Java 11.
Я уже некоторое время использую javaFX, но день назад, когда я создал новый проект, я заметил, что в пакете по умолчанию автоматически создается новый файл с именем (module-info.java), и я даже не могу удалите это!!.
Там написан следующий код:
module prog0 {
requires javafx.controls;
opens application to javafx.graphics, javafx.fxml;
}
К сожалению, во всех строках есть ошибки
1-я строка: Синтаксическая ошибка токена «модуль», ожидается интерфейс
2-я строка: Синтаксическая ошибка токена «.», Ожидается
3-я строка: ** Несколько маркеров в этой строке
- Syntax error on token "to", =
expected
- Syntax error on token ".", ,
expected
- Syntax error on token "to", =
expected
- Syntax error on token ".", ,
expected**
Используемые библиотеки:
1 ответ
Лучший ответ
Файл module-info.java выглядит довольно типично для модульных проектов Java (Java 9+). Обычно требуется javafx.controls и открыть ваше приложение (здесь фактически названное «application») для javafx. Я думаю, что это последнее утверждение относится к модулю javafx, который должен иметь возможность заглядывать в модуль, который имеет точку входа для программы.
Но расположение файла мне кажется подозрительным. Я не разбираюсь во всех сложностях, но я думаю, что файл лучше разместить непосредственно в каталоге / src, а не в пакете по умолчанию. Обычно файл module-info.java является верхним уровнем папки файлов, а исходный код программы — дочерней папкой.
Другими словами, файл module-info.java и файл пакета / application должны находиться в одной папке. По крайней мере, так все устроено в моих программах javafx и модульных программах Java.
РЕДАКТИРОВАТЬ: я заметил, что в вашем пути сборки указан Java 1.5! Эта Java не поддерживает модули. Модули были введены в Java 9.
1
Phil Freihofner
5 Авг 2021 в 00:34