Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Unable to get Java modular project to run on NetBeans 11.1

 
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying my hands on a very rudimentary Java modular project using openJDK14 on NetBeans 11.1.  However, it is turning out to be an exercise in futility. Each time I try to run the project, I get the message shown on the image insert below.  I need help and so I have attached the project layout in case somebody wishes to look at what I may be doing wrong.
Project-layout.pnp.PNG
[Thumbnail for Project-layout.pnp.PNG]
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Error message is shown below.
Error-message.png
[Thumbnail for Error-message.png]
 
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can run your application just fine. I'm on NetBeans 11.2 and I'm using OpenJDK 13.0.1.

I don't think it has to do anything with the module system. Maybe your NetBeans version is not compatible with your Java version. Java 14 is really new, and IDEs tend to lag behind a few months before they fully support a new platform version.

I suggest trying to run NetBeans on Java 13, and the project as well.

Additionally, I strongly advise using Maven to build your application instead of Ant.
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apology for the slow response.  I was actually trying out the recommendations.  Unfortunately, non has worked for me.  I have even downloaded and tried Apache NetBeans 11.3 to run the Java module project.  No luck! Things are getting for very frustrating. Does it have anything to do with the operating system?  I am using Windows 10, 64-bits edition, with latest updates. I mean, if I cannot successfully run such rudimentary program, I am beginning to feel that there is little hope for me in learning Java.

As for building Java programs on Maven, I have never been able to succeed in that too.  Example, look at the image insert below.  Each time I try creating Java program based on Maven, I get the following errors:

------------------------------------------------------------------------
Building mavenproject2 1.0-SNAPSHOT
------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.672 s
Finished at: 2020-04-21T11:59:45+01:00
Final Memory: 7M/27M
------------------------------------------------------------------------
Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): No such host is known (repo.maven.apache.org) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException


Maven-Project.pnp.PNG
[Thumbnail for Maven-Project.pnp.PNG]
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show Tools -> Options -> Java -> Maven.

Also show your Maven POM by copying and pasting it (no screenshot). Use [code=xml]<pom contents>[/code].
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<?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.mycompany</groupId>
   <artifactId>mavenproject2</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
   <properties>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       <maven.compiler.source>13</maven.compiler.source>
       <maven.compiler.target>13</maven.compiler.target>
   </properties>
</project>

Maven1.png
[Thumbnail for Maven1.png]
Maven2.png
[Thumbnail for Maven2.png]
Maven3.png
[Thumbnail for Maven3.png]
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you have the experimental features enabled?

Anyway, like I said before, download Java 13 and try that. I'm not sure if NetBeans supports Java 14 yet.
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have JDK 13 and JDK 14 in my computer.  So, now I have tried to create another Java program based on Maven with JDK 13.  The program still would not compile.


Scanning for projects...
                                                                       
------------------------------------------------------------------------
Building mavenproject4 1.0-SNAPSHOT
------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.778 s
Finished at: 2020-04-21T14:47:32+01:00
Final Memory: 7M/30M
------------------------------------------------------------------------
Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from/to central (https://repo.maven.apache.org/maven2): No such host is known (repo.maven.apache.org) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException







Maven4.png
[Thumbnail for Maven4.png]
Maven5.png
[Thumbnail for Maven5.png]
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a command line, can you ping repo.maven.apache.org?
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, see below.
commandline-output.pnp.PNG
[Thumbnail for commandline-output.pnp.PNG]
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to download the latest version of Maven and configure NetBeans to use that instead of the bundled version.
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next challenge is how to get NetBeans the downloaded Maven.  The error I have now is "The system cannot find the path specified".

Please see the image below and guide me as to how to set Maven Home.
Maven6.png
[Thumbnail for Maven6.png]
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to put the folder that's inside the unpacked archive (apache-maven-3.6.3, NOT apache-maven-3.6.3-bin) in some sensible location on your PC and add that in NetBeans.

For instance, I renamed the apache-maven-3.6.3 folder to C:\Program Files\Apache\Maven 3.6.3, and added that path to NetBeans.

You may also want to create an environment variable named M2_HOME with the value being the path of the Maven installation directory. Create another variable M2 that has the value %M2_HOME%\bin. Finally, prepend %M2%; to the PATH environement variable.

When you've done all that, run mvn -v from a command line interface to see if it works.
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Stephan.  For the first time, I was able to compile and run a Java program on Maven.  See my big greetings to the world, below.
HelloWorld.PNG
[Thumbnail for HelloWorld.PNG]
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The outcome of running mvn -v is shown below.
mvn.png
[Thumbnail for mvn.png]
 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Success!  That's great!
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sincere apology for reopening this thread.  My original challenge of not being able to run a Java modular project based on Ant remains unsolved.  
For whatever reason, I am not able to run the project from NetBeans IDE.  However, I can run it at the command line.  The Java modular project
(not NetBeans module project) was coded and compiled in NetBeans IDE.  I will really be happy to know what is happening.

The command line that I am using to run the Java modular project is as follows:
C:\Program Files\openjdk-14_windows-x64_bin\jdk-14\bin>java --module-path D:\***\ModularProjectOne\build\modules -m com.testing.one/com.testing.one.User
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add that the command line command that I am using to run the project was actually suggested by the NetBeans IDE at the end of the Build process. It is kind of strange that NetBeans knows the correct command line command that should be used, but does not know the correct things to do to run the program from its own environment.
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried deleting the projects and creating them again?
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I have not deleted the project and recreated it.  But I have created a new Java modular project. Still, I cannot run it from NetBeans IDE. As usual, I can run it from the command line.
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your NetBeans installation folder, can you set netbeans_jdkhome in etc/netbeans.conf to the installation folder of JDK 13? Restart NetBeans. Tell us what happens.

If it doesn't work, you need to take it up with Apache, I'm afraid.
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the change that I have just made to the netbeans.conf file.  
netbeans_jdkhome=C:\Program Files\OpenJDK14_And_OpenJFX14\openjdk-14_windows-x64_bin\jdk-14
The program still does not run in NetBeans IDE.
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the point was to change it to JDK 13, not JDK 14.
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
netbeans_jdkhome=C:\Program Files\Java\jdk-13.0.1
I have created a new Java modular project based on JDK13.0.1.  I can run the project from the command line, but it does not run in Netabens IDE. When I click the Run button, nothing happens.

C:\Program Files\Java\jdk-13.0.1\bin>java --module-path D:\Joe\JavaStuff\ProjectsWithNetBeans\JavaModularApplication2\build\modules -m newmodule/newpackage2.NewClass2
Output:  Say Hello World!
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the problem does not occur with a non-modular project?

When you say 'nothing happens', do you mean that NetBeans doesn't respond at all, or that you get a popup asking you to select a main class?
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apology for rather late response.  I can run non-Java modular projects in NetBeans IDE.

When I say nothing happens, I mean nothing happens. I click the Run button and NetBeans does not respond at all.
 
Stephan van Hulst
Saloon Keeper
Posts: 13394
296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know what you tell you other than that it appears like a corrupt NetBeans installation or configuration.
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was using NetBean 11.1 before now.  It was because of this inability to run Java modular project in Netbeans IDE that I downloaded NetBeans 11.3.  So, it fair to say that the problem is not due to corrupted installation. I do believe the challenges I am facing has a lot to do with configuration.  Yes!  But who can recommend the best way to configure NetBeans to run a Java modular project?  NetBeans compiles the projects without errors. It must be an appropriate runtime configuration that is missing. Who can help me with this?
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I am missing the right way to configure the VM options.
VM-Options.png
[Thumbnail for VM-Options.png]
 
Biniman Idugboe
Ranch Hand
Posts: 344
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The modulepath in the following image.  What is the correct way to configure it?
Run-time-Libraries.png
[Thumbnail for Run-time-Libraries.png]
 
reply
    Bookmark Topic Watch Topic
  • New Topic