C++ Code –> Executable –> OS –> CPU
Java code –> Class –> { “JVM win”, “JVM linux”, CPU that supports JAVA} –> OS –> CPU
Java is like a application (Your Java app) running in another application (JavaVM).
so you need cmd java to run your app (.class)
javac yourJavaApp.java java youJavaApp
add java bin directory path to system environment or user profile environment variable:
set path=c:\java\bin\location;%PATH%
export path=/java/bin/location:$PATH
export JAVA_HOME=/jre_dir/bin/java export PATH=/jre_dir/bin:$PATH
and in dos
set path = %PATH%;d:\jre_dir\bin set JAVA_HOME=d:\jre_dir\bin\java
java -verbose -jar MyApp.jar
// compare string new String("test").equals("test") //==> true //ref: http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
int num[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; System.out.println("size of num[]: " + num.length);
import java.util.ArrayList; private ArrayList<Item> items = new ArrayList<Item>(); System.out.println(items.size());
FlowLayout() //FlowLayout.LEFT, FlowLayout.CENTER, FlowLayout.RIGHT, FlowLayout.LEADING, FlowLayout.TRAILING GridLayout(int rows, int columns) BorderLayout() BoxLayout() GroupLayout() SpringLayout() //ref: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html
listTable.getTableHeader().getColumnModel().getColumn(0).setHeaderValue("IC No"); listTable.getTableHeader().repaint(); //ref: http://www.java.net/node/692818
for(int i=0;i<list.length;i++){ listTable.getModel().setValueAt(list[i].getICNO(), i, 0); listTable.getModel().setValueAt(list[i].getFirstName(), i, 1); listTable.getModel().setValueAt(list[i].getLastName(), i, 2); listTable.getModel().setValueAt(list[i].getTitle(), i, 3); listTable.getModel().setValueAt(list[i].getOrg(), i, 4); }
for (int i = 0; i < table.getRowCount(); i++) for(int j = 0; j < table.getColumnCount(); j++) { table.setValueAt("", i, j); } }
String[] n_arr=new String[3]; JTextField icno = new JTextField(); JTextField firstName = new JTextField(); JTextField lastName = new JTextField(); final JComponent[] inputs = new JComponent[] { new JLabel("IC NO"), icno, new JLabel("First Name"), firstName, new JLabel("Last Name"), lastName }; JOptionPane.showMessageDialog(null, inputs, "Member Creation", JOptionPane.PLAIN_MESSAGE); n_arr[0]=icno.getText(); n_arr[1]=firstName.getText(); n_arr[2]=lastName.getText();
Some UI design Tips:
panelA.setVisible(false); //ref: http://www.codecommit.com/blog/java/techniques-of-java-ui-development