Java Reference
In-Depth Information
Listing C-2.
A RowSetTest Class That Uses Classes from the javax.sql Package
// RowSetTest.java
package com.jdojo.profiles;
import java.sql.SQLException;
import javax.sql.rowset.JdbcRowSet;
import javax.sql.rowset.RowSetFactory;
import javax.sql.rowset.RowSetProvider;
public class RowSetTest {
public static void main(String[] args) {
try {
RowSetFactory rsFactory = RowSetProvider.newFactory();
JdbcRowSet jdbcRs = rsFactory.createJdbcRowSet();
// More code goes here
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
The source code for the
SwingTest
class uses the
javax.swing
package that is part of the full JRE. If you try
compiling the class targeting the
compact3
profile, it will generate compile-time errors because the
javax.swing
package is available in the full JRE, not in the
compact3
profile, as listed in Table
C-2
.
javac -profile compact3 SwingTest.java
SwingTest.java:4: error: JFrame is not available in profile 'compact3'
import javax.swing.JFrame;
^
SwingTest.java:8: error: JFrame is not available in profile 'compact3'
JFrame frame = new JFrame("Compact Profiles");
^
SwingTest.java:8: error: JFrame is not available in profile 'compact3'
JFrame frame = new JFrame("Compact Profiles");
^
3 errors
The following command using the full JRE compiles the
SwingTest.java
fine:
javac SwingTest.java
The following command will compile the
RowSetTest
class file fine as the command uses
compact3
as the
-profile
option that matches the packages used inside the
RowSetTest
class:
javac -profile compact3 RowSetTest.java