Netbeans Example App does not have main Method - netbeans

The code below was generated by netbeans. When I right click it there is an error that it does not have a main method. What should I do? It is on xubuntu using netbeans IDE 10 JDK 11 . I created the app using netbeans.org/kb/docs/java/quickstart.html. I right click HelloWorldApp.java and choose run. then I get the error .Error screenshot
/*
* 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 helloworldapp;
/**
*
* #author peter
*/
public class HelloWorldApp {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Hello World!");
}
}

Related

Could not analyse class: maybe not loaded or no autoloader in typo3 for export using phpexcel

I am writing an export feature using phpexcel library. I have included the library into typo3conf/ext/extension_name/Classes/Library/PHPExcel. And also included the file typo3conf/ext/extension_name/Classes/Library/PHPExcel.php. And injected this file into my typo3 extbase controller as
/**
* PHPExcel
*
* #var \VendorName\ExtensionName\Classes\PHPExcel
* #inject
*/
protected $PHPExcel;
And called this into my export function as
public function exportxlsAction() {
$objPHPExcel = new \PHPExcel();
}
On clicking the backend module it throws the error as
Could not analyse class: "VendorName\ExtensionName\Classes\PHPExcel" maybe not loaded or no autoloader? Class VendorName\ExtensionName\Classes\PHPExcel does not exist..
Why is it so?
Problems in your namespace. Just change it like below.
\VendorName\ExtensionName\Classes\PHPExcel to \VendorName\ExtensionName\Library
Also if you have added all PHPExcel library on this path \VendorName\ExtensionName\Classes\Library\PHPExcel then your name space like below.
\VendorName\ExtensionName\Library\PHPExcel
Another Way.
In your ext_emconf.php File. add below code.
'autoload' => [
'classmap' => [
'Classes',
'Classes/Library/PHPExcel/PHPExcel.php',
]
]
Your controller file code like below.
/**
* PHPExcel
*
* #var \PHPExcel
* #inject
*/
protected $PHPExcel = null;
And you function as it is. like below.
public function exportxlsAction() {
$objPHPExcel = $this->PHPExcel;
}
After replace this changes you need to once install/Uninstall Extension.

Append author onto JavaDoc Headers in existing files upon saving Eclipse

I want to automatically append my user tag to the class documentation when I edit an existing class from the following:
/**
*
*
* #author inoue.orihime
*
*/
#Entity
#Table
public class ..
To this:
/**
*
* #author inoue.orihime
* #author ichigo.kurosaki
*
*/
#Entity
#Table
public class ..
Is this possible on eclipse or using some 3rd library ?
The Javadoc for a class is defined as a Code Template in Window > Preferences > Java > Code Style > Code Templates. In this preference page, select Comments => Types, then you will see the default Javadoc for new classes/interfaces/enums/annotations. Click on the Edit button to change its content.

Get the command line arguments in NetBeans 7.1.2

I am using NetBeans 7.1.2. My error is:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at javaapplication1.JavaApplication1.main(JavaApplication1.java:17)
Java Result: 1
My program is:
package javaapplication1;
/**
*
* #author Administrator
*/
public class JavaApplication1 {
/**
* #param args the command line arguments
*/
public static void main(String[] ar) {
int a=Integer.parseInt(ar[1]);
System.out.println(a);
// TODO: Code application logic here
}
}
FYI, the first parameter is ar[0], for example in the command line below ar[0] is "123":
java JavaApplication1 123
See this web page for more information on Java command-line arguments.

NetBeans PHPUnit test generation ignoring #assert annotation

I have an abstract class where source code looks like this:
/*
* #assert (0) == NULL
*/
public static function factory($num) {
if ($num==0)
return NULL;
//do some other stuff
}
If I delete the previously generated test file and use the "Create PHPUnit tests", it creates a new unit test file that doesn't seem to have taken the assert into account at all:
/**
* #covers {className}::{origMethodName}
* #todo Implement testFactory().
*/
public function testFactory() {
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
I must be doing something silly, but I can't figure out what. Is the failure to expand the class name and method name in the generated #covers annotation perhaps a clue?
I'm running NetBeans 7.0.1 on a Mac with PHP 5.3.6 and PHPUnit 3.6.2.
All annotations must appear in DocBlock comments which start with /** and not /*. You're missing an asterisk.
/**
* #assert (0) == NULL
*/
public static function factory($num) {

How to use the JFace FileDialog from within an Eclipse plugin in a modeless way?

I am writing an Eclipse plugin, and in response to some action I am interesting in starting a series of operations (within a separate job). One of these operations is to request the user to provide a filename, which I'm trying to do with the JFace JDialog.
However, I'm not clear how to do this in a modeless way; for example, where do I obtain a display and shell? How do I ensure the UI continues to work while the developer can edit stuff in the dialog?
May be you could see how Eclipse itself does it:
FindAndReplaceDialog.java
/**
* Creates a new dialog with the given shell as parent.
* #param parentShell the parent shell
*/
public FindReplaceDialog(Shell parentShell) {
super(parentShell);
fParentShell= null;
[...]
readConfiguration();
setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE | SWT.RESIZE);
setBlockOnOpen(false);
}
/**
* Returns this dialog's parent shell.
* #return the dialog's parent shell
*/
public Shell getParentShell() {
return super.getParentShell();
}
/**
* Sets the parent shell of this dialog to be the given shell.
*
* #param shell the new parent shell
*/
public void setParentShell(Shell shell) {
if (shell != fParentShell) {
if (fParentShell != null)
fParentShell.removeShellListener(fActivationListener);
fParentShell= shell;
fParentShell.addShellListener(fActivationListener);
}
fActiveShell= shell;
}
It does manage its parent shell depending on the focus of the Dialog.
/**
* Updates the find replace dialog on activation changes.
*/
class ActivationListener extends ShellAdapter {
/*
* #see ShellListener#shellActivated(ShellEvent)
*/
public void shellActivated(ShellEvent e) {
fActiveShell= (Shell)e.widget;
updateButtonState();
if (fGiveFocusToFindField && getShell() == fActiveShell &&
okToUse(fFindField))
fFindField.setFocus();
}
/*
* #see ShellListener#shellDeactivated(ShellEvent)
*/
public void shellDeactivated(ShellEvent e) {
fGiveFocusToFindField= false;
storeSettings();
[...]
fActiveShell= null;
updateButtonState();
}
}
A ShellAdapter is provides default implementations for the methods described by the ShellListener interface, which provides methods that deal with changes in state of Shell.
The importent thing is that the style value should include SWT.MODELESS.
The style is one of the most important things in SWT you should look at, because you can control and initialize a lot only because of the styel value.