Creating new application (Java With Maven, Java Application) has main class built ignoring templates
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 13 release candidate
### What happened
Creating a new Java with Maven, Java Application generates a Java file with a main. The file is generated ignoring the available template for Java Main Class.
Somewhat unrelated to this issue, clicking on the nbfs: links did not cause any noticeable activity.
### How to reproduce
1. File | New Project
2. In popup, choose Java with Maven then Java Application
3. Hit finish on next pop up
4. Generated project has a MavenProject1.java file with a main
It has
```
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
*/
package edu.uab.mavenproject1;
/**
*
* @author name
*/
public class Mavenproject1 {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
```
There is an existing template viewable using Tools | Templates , select Java, then Java Main Class, open in editor
```
/*
* Author: ${user}
* Assignment: ${project.displayName} - ${course}
*
* Credits: (if any for sections of code)
*/
<#if package?? && package != "">
package ${package};
<#if superclass?? && superclass != "" && !superclass?starts_with("java.lang") && !superclass?matches(package + "\\.\\w+")>
import ${superclass};
<#if interfaces?? && interfaces != "">
<#list "${interfaces}"?split("\n") as interface>
<#if interface?? && interface != "" && !interface?starts_with("java.lang") && !interface?matches(package + "\\.\\w+")>
import ${interface};
/**
*
*/
<#if superclass?? && superclass != "">
<#assign extension = "${superclass}"[("${superclass}"?last_index_of(".") + 1)..]>
<#if interfaces?? && interfaces != "">
<#assign implementation = "">
<#list "${interfaces}"?split("\n") as interface>
<#assign implementation += "${interface}"[("${interface}"?last_index_of(".") + 1)..] + ", ">
<#assign implementation = "${implementation}"?remove_ending(", ")>
public class ${name}<#if extension?? && extension != ""> extends ${extension}<#if implementation?? && implementation != ""> implements ${implementation} {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
```
### Did this work correctly in an earlier version?
Apache NetBeans 12.6
### Operating System
MacOS 12.2.1 (Monterey) M1 Pro
### JDK
JDK 17
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
Note: the previous 12.6 did not add a starting file as part of project completion.
### Are you willing to submit a pull request?
_No response_
### Code of Conduct
Yes
Contributor guide
Research direction
Reproduce the File | New Project flow for Java with Maven and Java Application, then inspect how the generated main class is selected relative to Tools | Templates and the Java Main Class template. Done means the project wizard generates the main class from the available template rather than ignoring it; verify the result against the reported NetBeans 12.6 and 13 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100