Problem :
I try to create a web site for my project with Maven by reading an article of Batiste Witch : article,.
I met some difficulties : How to find mvn site command in Netbeans ?
Solution :
The solution is simple.
When you create a maven project, there is no Project Site directory in project java view.So you can't access to the Generate Site menu.
To reveal this menu you have to create a "site" directory in src directory.Then, you make run-> Clean and Build Main Project .After that you will see a Project Site directory in Project java view and you will be able to right click on it and generate site.
Screen shots and explanation are available here : mrhaki.blogspot.com
Wednesday, September 30, 2009
How to find mvn site command in Netbeans 6.7 ?
Monday, September 28, 2009
Netbeans : Create your own shortcut.
Problème :
You know eclipse shortcut but it doesn't exist in Netbeans.
Note : the complete shortcut list is available in menu Help -> Keyboard Shortcuts Card.
Solution : Create you own shortcut with netbeans macro.
Like excel, you can edit and save you macro.
Here is how you can do :
Image that you want delete a line with CTRL + D.
1) Start recording : Go Edit -> Start recording
2) Select one line by clicking severeal time on the line then delete it.
3) Stop recording by cliking on Edit -> Stop recording.
This dialog box appears :
Enter the name of the macro (ex:delete-line) then click OK.
You will show a similary window :
The last thing you have to do is "Set shortcut" and define your shortcut.
You know eclipse shortcut but it doesn't exist in Netbeans.
Note : the complete shortcut list is available in menu Help -> Keyboard Shortcuts Card.
Solution : Create you own shortcut with netbeans macro.
Like excel, you can edit and save you macro.
Here is how you can do :
Image that you want delete a line with CTRL + D.
1) Start recording : Go Edit -> Start recording
2) Select one line by clicking severeal time on the line then delete it.
3) Stop recording by cliking on Edit -> Stop recording.
This dialog box appears :
Enter the name of the macro (ex:delete-line) then click OK.
You will show a similary window :
The last thing you have to do is "Set shortcut" and define your shortcut.
Thursday, September 24, 2009
JAVA Certification SCJP : operators
Here is an SCJP certification exercise about operators.
Exercice :
class Arg {
public static void main(String[] args){
int i = 6;
if ( i && 12 ){
System.out.println("OK!");
} else {
System.out.println("KO!");
}
}
}
What is the result ?
A : OK!
B : KO!
C : compilation fails
D : An exception is thrown at runtime
Soultion :
The compilation will fail because of i && 12.The && and || work with boolean operators only !
Exercice :
class Arg {
public static void main(String[] args){
int i = 6;
if ( i && 12 ){
System.out.println("OK!");
} else {
System.out.println("KO!");
}
}
}
What is the result ?
A : OK!
B : KO!
C : compilation fails
D : An exception is thrown at runtime
Soultion :
The compilation will fail because of i && 12.The && and || work with boolean operators only !
Monday, September 21, 2009
New version of Eclipse : Eclipse 3.6 Helios M2
The new eclipse (Eclipse 3.6 Helios) milestone 2 is available !
There are many changes like New Open Implementation command and Extract Method improvements.
There are many changes like New Open Implementation command and Extract Method improvements.
Noop : new google programming langage which be made to be integrate on Sun's JVM.
Google has create a new langage which is done to be initialy integrated at the JVM.
The language's goal :
Noop says Yes to
* Dependency injection built into the language
* Testability - a seam between every pair of classes
* Immutability
* Syntax geared entirely towards readable code
* Executable documentation that's never out-of-date
* Properties, strong typing, and sensible modern standard library
Noop says No to
* Any statics whatsoever
* Implementation inheritance (subclassing)
* Primitives
* Unnece
it's seem interesting !
More information :
JVM summit conference
javaworld's article
Noop home page
The language's goal :
Noop says Yes to
* Dependency injection built into the language
* Testability - a seam between every pair of classes
* Immutability
* Syntax geared entirely towards readable code
* Executable documentation that's never out-of-date
* Properties, strong typing, and sensible modern standard library
Noop says No to
* Any statics whatsoever
* Implementation inheritance (subclassing)
* Primitives
* Unnece
it's seem interesting !
More information :
JVM summit conference
javaworld's article
Noop home page
Saturday, September 19, 2009
JAVA Certification SCJP : keyword
Question about keywords are often in SCJP exam.Be careful at C++ keyword that are different of JAVA keyword.The exam will try to make confuse about this.If you search, books and exercice,you can see that link : Certification Sun SCJP
These exercises will show common keyword question.
Exercise 1 :
Given the following :
public class Test {
public static void main(String [] args) {
System.out.println("Zest!");
}
public void assert {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Zest!
B Helllo
C Compilation fails
D An exception is thrown at runtime
Exercice 2 :
Given the following :
public class Test {
public static void main(String [] args) {
System.out.println("Zest!");
int true = 1;
System.out.println("true : " + true);
}
}
What is the result ? (choose one)
A Zest!
B Zest true: 1
C Compilation fails
D An exception is thrown at runtime
Exercice 3 :
public class Test {
public static void main(String [] args) {
System.out.println("Zest!");
transient int value = 10;
System.out.println("true : " + true);
}
}
What is the result ? (choose one)
A Zest!
B Zest true: 1
C Compilation fails
D An exception is thrown at runtime
Solution :
Exercise 1 :
Compilation will fail because assert is a reserved keywords. Be careful at this sort of question.It's often in test and very easy to miss it
Exercise 2 :
Compilation will fail because you can't name variable with a keyword name.
Exercise 3 :
Compilation will fail.Transient keyword is an attribut of a class.It's used in serialisation.
Example :
class Writeable implements java.io.Serializable {
public transient int var1 = 4;
public int var2 = 19;
}
These exercises will show common keyword question.
Exercise 1 :
Given the following :
public class Test {
public static void main(String [] args) {
System.out.println("Zest!");
}
public void assert {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Zest!
B Helllo
C Compilation fails
D An exception is thrown at runtime
Exercice 2 :
Given the following :
public class Test {
public static void main(String [] args) {
System.out.println("Zest!");
int true = 1;
System.out.println("true : " + true);
}
}
What is the result ? (choose one)
A Zest!
B Zest true: 1
C Compilation fails
D An exception is thrown at runtime
Exercice 3 :
public class Test {
public static void main(String [] args) {
System.out.println("Zest!");
transient int value = 10;
System.out.println("true : " + true);
}
}
What is the result ? (choose one)
A Zest!
B Zest true: 1
C Compilation fails
D An exception is thrown at runtime
Solution :
Exercise 1 :
Compilation will fail because assert is a reserved keywords. Be careful at this sort of question.It's often in test and very easy to miss it
Exercise 2 :
Compilation will fail because you can't name variable with a keyword name.
Exercise 3 :
Compilation will fail.Transient keyword is an attribut of a class.It's used in serialisation.
Example :
class Writeable implements java.io.Serializable {
public transient int var1 = 4;
public int var2 = 19;
}
Monday, September 14, 2009
JAVA Certification SCJP : fundamentals main
You must know the construction of the main method.
The exam will try to make confuse about this.If you search, books and exercice,
you can see that link : Certification Sun SCJP
Note : the solutions of the exercise are at the end.
Exercice 1 :
Given the following :
public class Test {
public static void main(String args) {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Helllo
B Hell
C Compilation fails
D An exception is thrown at runtime
Exercice 2 :
Given the following :
public class Test {
public static void main(String [] arg) {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Helllo
B Hel
C Compilation fails
D An exception is thrown at runtime
Exercise 3 :
Given the following :
public class Test {
public void main(String [] argS) {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Helllo
B Hel
C Compilation fails
D An exception is thrown at runtime
Exercise 4 :
Given the following :
public class Test {
public static void main(String [] test) {
System.out.println(test[0]);
}
}
and the command line evocation is
java Test X 1 t
What is the result ? (choose one)
A Test
B X
C 1
D t
C Compilation fails
D An exception is thrown at runtime
Solution :
Exercise 1 :
There is no [] that 's why, there is an error at execution.The compilator doesn't see
the main method.It see a method so when you launch your application, it thows an exception :
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: packet/Test)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Test. Program will exit.
The answer is D.
Exercise 2 :
You will see Helllo on the scree.
Note : you can name the main method argument differently if you wish.
Exercise 3 :
The correct answer is D because the compilator search main method but there is not correct
main method like public static void main(String [] args) {
Exercise 4 :
The good solution is B (X).
The exam will try to make confuse about this.If you search, books and exercice,
you can see that link : Certification Sun SCJP
Note : the solutions of the exercise are at the end.
Exercice 1 :
Given the following :
public class Test {
public static void main(String args) {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Helllo
B Hell
C Compilation fails
D An exception is thrown at runtime
Exercice 2 :
Given the following :
public class Test {
public static void main(String [] arg) {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Helllo
B Hel
C Compilation fails
D An exception is thrown at runtime
Exercise 3 :
Given the following :
public class Test {
public void main(String [] argS) {
System.out.println("Helllo");
}
}
What is the result ? (choose one)
A Helllo
B Hel
C Compilation fails
D An exception is thrown at runtime
Exercise 4 :
Given the following :
public class Test {
public static void main(String [] test) {
System.out.println(test[0]);
}
}
and the command line evocation is
java Test X 1 t
What is the result ? (choose one)
A Test
B X
C 1
D t
C Compilation fails
D An exception is thrown at runtime
Solution :
Exercise 1 :
There is no [] that 's why, there is an error at execution.The compilator doesn't see
the main method.It see a method so when you launch your application, it thows an exception :
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: packet/Test)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Test. Program will exit.
The answer is D.
Exercise 2 :
You will see Helllo on the scree.
Note : you can name the main method argument differently if you wish.
Exercise 3 :
The correct answer is D because the compilator search main method but there is not correct
main method like public static void main(String [] args) {
Exercise 4 :
The good solution is B (X).
Subscribe to:
Posts (Atom)