Java compilation warning
While generating the JAR file (successfully) in Netbeans 7.1.1
I ran into this warning:
...
warning: [options] bootstrap class path not set in conjunction with -source 1.6
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
...
What does it mean? Also, does Java runtime affect JAR (application) compatibility?
When I run the JAR in XP
and Ubuntu
, the app seems fine, but when I try to run it on Fedora
, it doesn't use full screen and doesn't have a context menu when I'm right click JTable
. What should I do about it?
Some code snippets:
This code calls JFrame a when it loads into full screen mode, but it doesn't work on Fedora.
this.setVisible(false);
frmMain xForm = new frmMain();
xForm.setLocationRelativeTo(null);
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
xForm.setMaximizedBounds(e.getMaximumWindowBounds());
xForm.setExtendedState(xForm.getExtendedState()|JFrame.MAXIMIZED_BOTH );
xForm.setVisible(true);
When I click on the button JTable
to show the context menu it works fine in Windows
, but not in Fedora
and Ubuntu
.
private void tableItemMouseReleased(java.awt.event.MouseEvent evt) {
if ( SwingUtilities.isRightMouseButton( evt ))
{
int r = tableItem.rowAtPoint(evt.getPoint());
if (r >= 0 && r < tableItem.getRowCount())
{
tableItem.setRowSelectionInterval(r, r);
}
else
{
tableItem.clearSelection();
}
int rowindex = tableItem.getSelectedRow();
if (rowindex < 0)
return;
if (evt.isPopupTrigger() && evt.getComponent() instanceof JTable )
{
pmItem.show(evt.getComponent(), evt.getX(), evt.getY());
}
}
}
UPDATE 1
adding -Xlint:unchecked
in Compile options I got the following warnings:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Documents and Settings\Totet\My Documents\NetBeansProjects\DCWD_DepreciationMonitoringSystem\src\DCWDDMS\frmItemDepreciation.java:432:
warning: [unchecked] unchecked call to addElement(E) as a member of the raw type Vector
newRow.addElement(rs.getObject(i));
where E is a type-variable:
E extends Object declared in class Vector
C:\Documents and Settings\Totet\My Documents\NetBeansProjects\DCWD_DepreciationMonitoringSystem\src\DCWDDMS\frmMain.java:351:
warning: [unchecked] unchecked call to addElement(E) as a member of the raw type Vector
newRow.addElement(rs.getObject(i));
where E is a type-variable:
E extends Object declared in class Vector
C:\Documents and Settings\Totet\My Documents\NetBeansProjects\DCWD_DepreciationMonitoringSystem\src\DCWDDMS\frmNewItem.java:831:
warning: [unchecked] unchecked call to addElement(E) as a member of the raw type DefaultComboBoxModel
model.addElement(resultList.getString(1));
where E is a type-variable:
E extends Object declared in class DefaultComboBoxModel
C:\Documents and Settings\Totet\My Documents\NetBeansProjects\DCWD_DepreciationMonitoringSystem\src\DCWDDMS\frmNewItem.java:833:
warning: [unchecked] unchecked call to setModel(ComboBoxModel<E>) as a member of the raw type JComboBox
cmbAccount.setModel(model);
where E is a type-variable:
E extends Object declared in class JComboBox
5 warnings
source to share
Source / Binary Setting
Here's an explicit way to set the source and target of your project explicitly. Most of the time, you don't need to mess with this once you set up your project based Java platform in netbeans.
- Right click on Project and select Properties.
- Select sources
- Set source level to 6 (source / binary format)
- Click the OK button.
Unsafe Operation Warning
I ignore the "unsafe operation warning" altogether. But if you want to know why this is shown, recompile with the option -Xlint:unchecked
(in step 5 above) and it will explain what is reported as unsafe and why.
Fedora UI Issues
On Fedora, check your path to make sure you are not using the default GNU Java runtime.
go to command line and type
java -version
to see what it returns. It should return information about Java (sun). Otherwise you will run into problems, especially with Swing / UI stuff.
source to share
javac
will happily adapt to this release -source
and generate class files that are compatible with -target
, but it can't know that you haven't accidentally used an invalid function unless you tell her to use the JDK. Typically, the IDE allows you to choose among the installed JDK versions to reduce your risk.
Application: In NetBeans, you can specify Java Platform
in File > Project Properties > Library
.
Application: ComboBoxModel
became common for Java 7. When you target 1.6, you need to install the corresponding JDK. NetBeans should find it on startup and display it among Tools > Java Platforms
.
Appendix: If you've decided to target Java 7, here's an example.
source to share