Friday, December 4, 2009

GWT [ERROR] No source code is available for ...GWTTestCase

Problem :


You have the following error:
[ERROR] Line 11: No source code is available for type com.google.gwt.junit.client.GWTTestCase;
did you forget to inherit a required module?



Solution
:

In your module file(*.gwt.xml), simply add :

"< name="com.google.gwt.junit.JUnit">"

Friday, November 27, 2009

Eclipse GWT_EXTERNAL_BROWSER

Problem :


When you compile in hosted mode, you have the following error :
[ERROR] Unable to find a default external web browser

[WARN] Try setting the environment variable GWT_EXTERNAL_BROWSER to your web browser executable before launching the GWT shell



Solution :


In eclipse, Go on Run -> Run Configurations.Then, choose your google's project and click on Environment.The last thing, you have to do is to add the variable GWT_EXTERNAL_BROWSER with the value firefox.





Tuesday, November 24, 2009

Java 7 Closures news

Since Devoxx09, there are many proposition and talk about closures.
I you want a summary about this, go on : Summary about closure proposals

Friday, November 20, 2009

GWT : static ressources and public directory


Problem


I've just began GWT's learning and I met a problem with static resources.Where can I put my image, css or js file.On the web, I found that you have to put it on public directory.But where create this public directory ?

Solution

You have to create a public directory at the same level of the *.gwt.xml file.In my example, it's in src/com/google/gwt/sample/stockwatcher(see image below).
Then when you will run run the app, files will be copy in the war directory automatically.
The last thing you have to do is to put the path of the resources in the html file similar to that :

"<"link type="text/css" href="stockwatcher/css/start/jquery-ui-1.7.2.custom.css rel="Stylesheet"">"
"<"script type="text/javascript" language="javascript" src="stockwatcher/js/jquery-1.3.2.min.js""/" "<"script type="text/javascript" language="javascript" src="stockwatcher/js/jquery-ui-1.7.2.custom.min.js""/>"

Here is a real example (click on the picture to enlarge) :



Google OS is available ! Chrome OS

Here is a fresh news : Google announced that its OS is available.
This is an Operating System based entirely on Internet and so on Chrome browser.


- Every software are on internet

- Startup instantly when you push the power button.
- Security : Data are crypted.


Source code is available and you can build it.
Note : The source code is open source.


More infos on
:
Youtube
Chrome Project

Thursday, November 19, 2009

Java 7 : Closures will be in jdk7 !


A big surprise today at the Devoxx.Closures will be on jdk7 (Some time before Sun says that closure will be not at the jdk7).
We don't know yet witch syntax will be choose.There is several proposals
(list ).But one seems to be prefer (Neal Gafter).

Friday, November 13, 2009

Go : a new Google programming langage system

Google has announced a new system programming langage. See GO on blog.
The goal of this programming langage is modernize system langage (like C) with library dependencies, with thread management, with garbage collector, with native multithread management, with better syntax...
In the FAQ, Google say that it use Go internaly but not in production.

So we can see that Goole make many langage and news (see also
SPDY).
Note, it's just before the arrival of the Google OS ...


Annonce Google
Site web Langage Go

Maven : Advantages and drawbacks

Yesterday, I went to the Marseille JUG.The subject was "About Maven" presented by Arnaud Héritier.I didn't know a lot Maven So here is the summary, i can do :

Advantages:



- Manage library version.
It's a major advantage ! Maven manage library version whereas Ant didn't.Before, all the library was in the lib dirctory.Now Maven can tell for a version, the library it used.

Note : Ant can do that with Ivy

- Maven Conventions.
- It exists plugins on IDE like Eclipse, Netbeans, intellij idea


Drawbacks :



- Library repositories are not always safe.
In maven, you can define one or severeal repositories of library on the net.However, sometimes if the management of library are bad, you can have compile error or differences between jar on different repositories.
- Maven Conventions.
- Learning Maven is long in comparaison of Ant.
- http://blog.codeeg.com/2008/06/28/25-things-i-hate-about-maven/

To conclude, Maven is became the build tool.Enterprise use it more and more.
The major drawback is that you need to learn it but, at the end you will have benefit with maintenance and use.That's not the case of Ant.



Tuesday, November 10, 2009

Test Google Web Toolkit

Today, I make a web site for my association.I decide to make this web site with GWT.It permits me to know GWT.
First things we can say is that Google give you all you needs :
- Good doucmentation.
I've begin to read it.I can say that the documentation is easy to understand and it has no error : GettingStarted.
- An eclipse plugin.
- You can deploy your web app free whit Google (GoogleAppEngine)

An other important point and that you use java !



Sunday, November 8, 2009

Java Certification SCJP : String

Here is common question about String.


Exercise :

public class test {

public static void main(String args) {
String s = "toto";
System.out.println("Size of s:" + s.length);
}
}


What is the result ? (choose one)

A Size of s:4
B Size of s:3
C Compilation fails
D An exception is thrown at runtime














Solution :

The answer is C because String have a method that's call length() but it has no attribute length.
Note that it's really easy to be a mistake here !

Tuesday, October 27, 2009

Netebans 6.8 available

The final release will be available in december.For now, you have the beta version.If you want to see the news of this version : Netbeans 6.8 beta

Friday, October 23, 2009

Exercice certification SCJP

Here is a small SCJP exercice to practice :


Given the following :

public class Test {

public int myTest = 2;
private String str;
public static void main(String [] args) {

for(int i=1;i<12;i++){
int myValue = 2;
System.out.println("great test !");
if (i== 5) {
myValue++;
System.out.println("myValue=" + myValue);
}
}
myValue++;
System.out.println("myValue=" + myValue);
}
}

What is the result ? (choose one)


A myValue=3 myValue=4

B myValue=3 myValue=3

C Compilation fails

D An exception is thrown at runtime









Solution

The solution is C because myValue exist only in for statement.

Friday, October 16, 2009

SCJP exercise : private, protected and public

Exercise :

public class Test {

public int myTest = 2;
private String str;
public static void main(String [] args) {
System.out.println("myTest=" + myTest);

}

}

What is the result ? (choose Two)

A myTest=2
B myTest=0
C Compilation fails
D An exception is thrown at runtime







Solution

C . The compilation will fail because we are in the main() method and we haven't instantiate Test.To make it working on solution should be :
Test monTest = new Test();
System.out.println("monTest=" + monTest.myTest);

Wednesday, October 14, 2009

The end of keyboard and mouse ? 10GUI

Here is a fun news !
R. Clayton Miller invents a new system for keyboard and mouse.
You can see a video on 10GUI

Saturday, October 10, 2009

SCJP exercise : identifiers

Exercise 1 :

Given the following :

public class Test {
public static void main(String [] args) {
int $test = 10;
System.out.println("$test=" + $test);

}

}

What is the result ? (choose Two)

A $test=10
B $test=null
C Compilation fails
D An exception is thrown at runtime


Exercise 2

Given the following :

public class Test {
public static void main(String [] args) {
int $2test = 10;
System.out.println("$2test=" + $2test);

}

}

What is the result ? (choose Two)

A $2test=10
B $test=null
C Compilation fails
D An exception is thrown at runtime














Solution Exercise 1 :

The solution is A. An identifier can begin with $ or _ .

Solution Exercice 2 :

The correct answer is A. An identifier can't begin with a number but can have a number.

Wednesday, October 7, 2009

SCJP exercices

Hi all,

I will publish some SCJP exercices next saturday and every week.
All comments will be appreciate !

Wednesday, September 30, 2009

How to find mvn site command in Netbeans 6.7 ?

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

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.

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 !

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.


See the link above for more details :

eclipse-news-M1

eclipse-news-M2

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

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;
}

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).

Saturday, August 29, 2009

Certification Sun JAVA SCJCP : How to prepare ?

I've passed my Java Certification (SCJP) with success and i have some advice.I think that theses advices are also available for other Java certification (scdjws, j2ee certification) and also certifications in general.If you have question about certification voucher and certification prometric, please make asearch on Google.In my blog, I will give you advice about materials needed and exercises only.So, if you want to be certified, read the following :

To succeed more easily at this exam, you must have a book and practice exam.

- Advice 1 : Get a good book.

If you want to succeed quickly the certification exam, buy a certification book.(Moreover, it's often possible to have a certification pdf so you can read everywhere !)
I know it will cost you some money but you will have full course and complete teach.You will will win time and it will replace a good teacher ! If you search on the web, you will find a lot of certication courses but often there are not complete.
A good book is : SCJP Sun certified programmer for JAVA 6 310-065 (Katherine Sierra, Bert Bates).In this book will learn you all that you need to know and we will show typical question you have at the exam, a lot of tips about question and it will give you also exercices.


- Advice 2 : Practice and make certification test.

You need to practice and pratice ... Training is the key ! If you passed all practice exams, it means that you are ready. To that there is software like : www.whizlabs.com/scjp.../scjp.html
and also my blog :-)
You can also prepare yourself but it's more easier and faster to have good materials.

- Article 3 : Get informed

It's also usefull to look on the web news.Here is my list of best java web site (http://totalprogus.blogspot.com/2009/08/les-meilleurs-sites-java.html).

To conclude, if you want to be java certifed, get a good book and make a lot of certification exercise.It will replace expensive course.

Sunday, August 16, 2009

Best Java web sites

Here is my favorite web site list :

http://java.developpez.com/ : It's for me the best french web site.There is lot of tips, good forum.
http://www.infoq.com/ : This web site present a lot of technical article and most of them are very advanced and are made by java guru.
http://www.javaworld.com/ : Lot of complete article on java.
http://www.jboss.org/webinars

Newsletter :
http://www.javaspecialists.eu/

If you have other web site, said to me ! I will put this list up to date.

Thursday, August 13, 2009

New google web search : cafeine

Google has announced the new beta version of this web search.
At this moment, it's not always available but i can make some comparison and it is
faster than before !

http://googlewebmastercentral.blogspot.com/2009/08/help-test-some-next-generation.html

Sunday, August 9, 2009

Netbeans : cannot set LC_CTYPE locale

Problem :

When i configure subversion for Netbeans, I had this problem :



Solution :


The problem is that LC_CTYPE was unknown.
In fact, you have to check that this variable value is correctly spell.
To do that, you can do : locale -a

Example :
$ locale -a
C

POSIX
fr_FR fr_FR.iso88591
fr_FR.iso885915@euro
fr_FR@euro


Next, you have to check in the configuration file :
On gentoo :
vi /etc/env.d/02locale


Example :
vi /etc/env.d/02locale

LANG="fr_FR.iso885915@euro"
LC_COLLATE="C"

=> You must have LANG variable initializes with one of the result of the command : locale -a

If you want, you can also let every Linux user to configure their own variable.

vi ~/.bashrc

Example :
vi ~/.bashrc
export LANG="fr_FR.iso885915@euro"
export LC_ALL=C





Friday, August 7, 2009

Netbeans : Cannot execute ... Check external browser configuration.

Problem :

If you have the following error when you click on view -> Web browser :



Solution :

You have to check firefox parameters in Tools -> Options :

Then click Edit and you will see something like that :

Then you have to modify this parameters.
In my case (firefox 3.0.11), you have to put {url} like that :


You will found more information directly on sun's blog :
http://blogs.sun.com/NetBeansSupport/entry/firefox_and_netbeans

Overriding paint dans Netbeans.

For my first post, here is a small tips about the use of Netbeans/

Problem:

If you wan to override the paint method in Netbeans, you can't !
In fact, if you use the Netbeans editor you will obtain a a class like that :
*/
public class PacketMakerView extends FrameView {
Lien
public PacketMakerView(SingleFrameApplication app) {
Et il vous sera impossible d'overrider la méthode paint.

Solution:
In design interface, make a right click on the component then choose customize code.
To override paint, you have to change the initialize with "custom creation".


So now, it's possible to override paint method !

test = new javax.swing.JLabel()
{
public void paint(Graphics g) {
super.paint(g);
// ...
}
}