Archive

Author Archive

Troubleshooting Glassfish with HADB

Yesterday I played GlassFish 2.1.1 with HADB, there are two servers. First server I have a database status is nonoperational and second server status is stopped. Here workaround that I did.

Database status NonOperational

cypher_2

For this case the solution is quite easy. Read more…

Install Glassfish 2.1.1 with HADB

The following article is a note of my activity today play with high availability cluster in Glassfish 2.1.1.
The contents of this article can be use to learn to make HA-cluster in Glassfish 2.1.1 but not intended for production.

Note: when try to install Glassfish using java that came with installer. If you use java with higher versions then you will encounter an error when running the node agent and cluster. Read more…

Categories: JAVA Tags: , , ,

My JAVA Note

Categories: Umum

Class Members

Class members means methods and instance (nonlocal) variable. If a class cannot be accessed, its members cannot be accessed.

 

Access Modifier

For class members, access means:

  1. Can access a member of anotehr class.
  2. Can inherit a member of it superclass.

Class members have four access control level:
public
Can be accessed by all other classes, even in other package.

private
Can be accessed only by code in the same class.
Not visible to sublcass, so private members cannot be inherited.
For best practice, instance variable must be mark by private. There can be access by methods (mark by public).

protected and default
Default members can be acces only by classes in the same package.
protected members can be accessed by other classes in the same package, plus subclasses regardless of package.
For subclasses outside the package, the protected member can be access only through inheritance.
A protected member inherited by subclass from another package is not accessible to any other class in the subclass package, except for the subclass own subclasses.
Local variables declaration cannot have access modifier. The only one modifier is final. They don’t get default value, you must initialized before use.

 

Read more…

Categories: JAVA

Array

Declaring an array:

int[] key;
Thread[] threads;
String[][] occupantName;

Initialized array:

int[] key = new int[5];
Thread[] threads = new Threads[4];
String[][] occupantName = new String[10][]; //first bracket must given an size, second is optional.
int[] carList = new int[]; //will not compile, need size
String[] days = {"Sunday", Monday", Tuesday", "Wendsday", "Thirdday", "Friday", "Saturday"}; //the size determined by the number of comma-separated items between the curly braces

Note:

  1. Arrays can hold primitives or objects, but the array itself is always an object.
  2. When you declare an array, the brackets can be left or right of the name.
  3. It is never legal to include the size of an array in the declaration.
  4. You must include the size of an array when you construct it (using new) unless you are creating an anonymous array.
  5. Elements in an array of object are not automatically created, although primitive array elements are given default value.
  6. You’ll get a NullPointerException if you try to use an array element in an object array, if that element does not refer to a real object.
  7. Arrays are indexed beginning with zero.
  8. An ArrayIndexOutOfBoundException occurs if you use a bad index value.
  9. Arrays have a length variable whose value is the number of array elements.
  10. The last index you can access is always one less than the length of the array.
  11. Multidimensional arrays are just arrays of arrays.
  12. The dimension in a multidimentional array can have differeny lengths.
  13. An array of primintives can accept any value than can be promoted implicitly to the array’s declared type. Example byte variable can go in an int array.
  14. An array of object can hold any object that passes the IS-A (or instanceof) test for the declared type of the array.
  15. If you assign an array to the previously declared array references, the array you’re assigning must be the same dimension as the reference you’re assigning to.
  16. You can assign an array of one type to a previously declared array reference of one of is supertypes.

 

 

Categories: JAVA

Enum

  1. An enum specifies a list of constant value asigned to a type.
  2. An enum is not a String or int, an enum constant type is the enum type.
  3. An enum can be declared outside or inside a class, but not in a method.
  4. An enum declared outside a class mus not be marked static, final, abstract, protected or private.
  5. Enums can contain constructors, methods, variables and constant class bodies.
  6. enum constants can send arguments to the enum constructor.
  7. enum constructors can have arguments and can be overloaded.
  8. enum constructors can never been invoked directly in code. They are always called automatically when an enum is initialized.
  9. The semicolon at the end of an enum is optional.
  10. MyEnum.value() return an array of MyEnum’s values.

Read more…

Categories: JAVA

Method with var-args

Rules for var-args:

  1. When you declare a var-arg parameter, you must specify the type of argument(s) this parameter of your method can receive.
  2. To declare a method using var-arg parameter, you follow thw type with an ellipsis (…), a space and then the name of the array that will hold the parameter recieve.
  3. It’s legal to have other parameters in a method that uses a var-arg.
  4. The var-arg must be the last parameter in the method’s signature, and you can have only one var-arg in a method.
void doSomething(int... a) { }
void doSomethind2(String a, int... b) { }

//illegal
void doSomething3(int... a, int b) { }
void doSomething4(int... a, int... b) { }

Categories: JAVA

Class

Source file declaration rules:

  1. There can be only one public class per source code file. If there is a public class, the name of the file must match the name of the public class. If there is no a public class, the file can be have a name different with a class name.
  2. Comments can appear at the beginning or end of any line in the source code file.
  3. If the class is part of a package, the package statement must be the first line in the source code file.
  4. If there are import statements, they must go between the package statement and the class declaration.
  5. import and package statements apply to all classes within a source file. There’s no way to declare multiple classes in a file and have them in different packages, or use different imports.
  6. A file can have more than one nonpublic class.

Read more…

Categories: JAVA

Java Identifier

  1. Identifier must start with a letter, a currency character ($), or an underscore (_). Identifier can’t start with a number.
  2. After the first character, identifier can contain any combination of letters, currency characters, connecting characters, or numbers.
  3. Identifier in Java are case-sensitive. foo and Foo are two different identifiers.
Categories: JAVA

Apache http server – Glassfish error 404

Dua hari ini saya dipusingkan dengan error saat request dari apache http server mendapat respon 404 dari glassfish.

respon normal

 

 



http server berjalan normalrespon gssaat request apps ke glassfish

Saya sudah cek tidak ada masalah dengan konfigurasi pada apache dan glassfish Read more…

Follow

Get every new post delivered to your Inbox.