Non-serializable attribute with name javax.zkoss.zk.ui.Session

The error:

java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute with name javax.zkoss.zk.ui.Session

The solution:
**edit zk.xml, add


Access to Tomcat server has not been authorized

For the first time, when I try to deploy a project using Netbeans, i got this message,


Deployment error:
Access to Tomcat server has not been authorized. Set the correct username and password with the “manager” role in the Tomcat customizer in the Server Manager.
See the server log for details.
After I googling, the solution,
– edit the content of C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.18\conf\tomcat-users.xml file.
-make sure you have role = manager and user that have manager role, like this
<role rolename=”manager”/>
<role rolename=”standard”/>
<user username=”admin” password=”pwd” roles=”standard,manager”/>
-save the file and restart Tomcat server


Sendkey method in Java

I want to make my software interface so user can move the focus from one textfield to another by pressing enter to move focus forward to next field, just as like when press tab key. So in another word, i want to replaced ENTER key code by TAB key code, if in VB programming, usually i use SendKeys “{TAB}” in KeyDown event.

And then here some code that maybe can work as i want to, another way that work it, please info it for me, thanks

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SendKeyTest extends javax.swing.JFrame {

private Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

private javax.swing.JTextField text1;
private javax.swing.JTextField text2;

Robot r;

public SendKeyTest() {
text1 = new javax.swing.JTextField();
text2 = new javax.swing.JTextField();

setTitle( “Test SendKey” );

getContentPane().setLayout( null );

text1.setBounds( 10, 20, 100, 30 );
text2.setBounds( 10, 50, 100, 60 );

try {
r = new Robot();
} catch (AWTException ex) {
ex.printStackTrace(); // for Robot()

text1.addKeyListener (new KeyAdapter () {
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {

text2.addKeyListener (new KeyAdapter () {
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {

setDefaultCloseOperation( javax.swing.WindowConstants.EXIT_ON_CLOSE );
setSize( 360, 360 );
setResizable( false );
setLocation( d.width / 2 – getWidth() / 2, d.height / 2 – getHeight() / 2 );
setVisible( true );

private void sendKey(int keyCode) {
r.delay(500); // for you to see the keystroke

public static void main( String args[] ) {
SendKeyTest sk = new SendKeyTest();

Get MAC Address with java

import java.util.*;
import java.util.regex.*;

public class GetMac
public static void main(String[] args)
throws IOException
String address = new GetMac().getMacAddress();

public String getMacAddress() throws IOException
String macAddress = null;
String command = “ipconfig /all”;
Process pid = Runtime.getRuntime().exec(command);
BufferedReader in =
new BufferedReader(
new InputStreamReader(pid.getInputStream()));
while (true) {
String line = in.readLine();
if (line == null)
Pattern p = Pattern.compile(“.*Physical Address.*: (.*)”);
Matcher m = p.matcher(line);
if (m.matches()) {
macAddress =;
return macAddress;


I have face error in running a compiled java class file.
Exception in thread “main” java.lang.UnsupportedClassVersionError: <class name>
(Unsupported major.minor version 50.0)

This error is caused when you compile a .java file with one version of JDK
and running the .class file with a different version of JVM
(the version of JDK is newer than JVM running .class file).

To check what version of your JDK or JVM, try this

javac -version
=> javac 1.6.0_12

java -version
=> java version “1.4.2_03”
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

You can see there are different version, because you have install more than one version of java
so to fix this
set path=C:\Program Files\Java\jdk1.6.0_12\bin;%path%

but keep in mind, in c:\windows\system32, there is java.exe, so your path of c:\windows\system32 must place behind
set path=C:\Program Files\Java\jdk1.6.0_12\bin;c:\windows\system32;%path%

‘javac’ is not recognized as an internal or external command

1. Go to and download the latest Version of Java SDK or any Jave SDK that your requirement and install on your system.

2. Accept all of the defaults and suggestions, but make sure that the location where Java will be installed is at the top level of your C: drive.
Click on “Finish.” You should have a directory (folder) named C:\j2sdk1.5.0_04, with subfolders C:\j2sdk1.5.0_04\bin and C:\j2sdk1.5.0_04\lib

3. Modify your system variable called “PATH” (so that programs can find where Java is located).
To do this for Windows 2000 or XP, either right-click on the My Computer icon or select “System” on the control panel.
When the window titled “System Properties” appears, choose the tab at the top named “Advanced.”
Then, click on “Environment Variables.”
In the bottom window that shows system variables, select “Path” and then click on “Edit…” Add C:\j2sdk1.5.0_04\bin as the first item in the list.
Note that all items are separated by a semicolon, with no spaces around the semicolon. You should end up with a path variable that looks something like

For Windows 98 or ME, open the file AUTOEXEC.BAT in Notepad. You should find a line in this file that begins
Modify this line to add C:\j2sdk1.5.0_04\bin; immediately after the equals sign.

4. Modify or create a system variable called “CLASSPATH,” as follows.
In the lower “System Variables” pane choose “New…”
and type in Variable Name “CLASSPATH” and value (note that it begins with dot semicolon).;C:\j2sdk1.5.0_04\lib

5. To test Java to see if everything is installed properly, open a command window (a DOS window)
and type the command “javac” The result should be information about the Usage of javac and its options.
If you get a result that “‘javac’ is not recognized as an internal or external command, operable program or batch file” then there is a problem
and Java will not work correctly.