Παρασκευή 27 Μαρτίου 2009
JPA implementations comparison: Hibernate, Toplink Essentials, Openjpa, Eclipselink
http://terrazadearavaca.blogspot.com/2008/12/jpa-implementations-comparison.html
Παρασκευή 20 Μαρτίου 2009
Eclipse Shortcuts
Just press Ctrl + Shift + L !
http://www.allapplabs.com/eclipse/eclipse_shortcuts.htm
http://codeofdoom.com/wordpress/2009/03/05/favorite-eclipse-shortcuts/
Παρασκευή 6 Μαρτίου 2009
Ημερολόγιο
10.00: Γενική Συνέλευση & Κοπή Πίττας Hellug
Τετάρτη (11/3/09) έχουμε και λέμε:
19:00: Παρουσίαση Android στο PLUG
Παρασκευή 27 Φεβρουαρίου 2009
J2ee Start a class when application server starts
1) create a new class that implements ServletContextListener.
then implement the two methods: contextInitialized(ServletContextEvent event) and contextDestroyed(ServletContextEvent event).
example:
public final class MyContextListener implements
ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
/* This method is called when the servlet context is
initialized(when the Web Application is deployed).
You can initialize servlet context related data here.
*/
MainThread mainthread1 = new MainThread();
mainthread1.start();
}
public void contextDestroyed(ServletContextEvent event) {
/* This method is invoked when the Servlet Context
(the Web Application) is undeployed or
WebLogic Server shuts down.
*/
System.out.println("goodbye");
//thread's clean up code
}
}
Then add:
under the web-app of web.xml file.
That's it!
Τετάρτη 25 Φεβρουαρίου 2009
Android get Screen orientation
[code]int orientation = getWindowManager().getDefaultDisplay().getOrientation()[/code]
and checking if it equals on of the following...
Configuration.ORIENTATION_PORTRAIT
Configuration.ORIENTATION_LANDSCAPE
...
Δευτέρα 23 Φεβρουαρίου 2009
Eclipse line break [wrap]
Καλό χρυσό όμορφο το eclipse, αλλά ο formater του μου έσπαγε τα νεύρα όταν "δίπλωνε" τις γραμμές στον κώδικα κατα το source formating λες και δούλευα σε 13'' οθόνη...
Μετά απο αρκετό καιρό, μια καλή ημέρα (σήμερα) αποφάσισα να το ψάξω λίγο περισσότερο και να βρω μια λύση.
Έχουμε και λέμε λοιπόν:
Windows -> Preferences -> Java -> Code Style -> Formatter -> Edit -> Maximum line width.
Επίσης για αυτούς που δεν θέλουν ΚΑΘΟΛΟΥ wrapping, μπορούν να το αλλάξουν, πειράζοντας το πεδίο "Line wrapping policy" σε Do not wrap.
Do not wrap my code λοιπόν bitch!
Σάββατο 14 Φεβρουαρίου 2009
Android unknown socket error -1
[code]E/OSNetworkSystem( 164): unknown socket error -1
W/System.err( 164): java.net.SocketException: unknown error
W/System.err( 164): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl(Native Method)
W/System.err( 164): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocket(OSNetworkSystem.java:79)
W/System.err( 164): at org.apache.harmony.luni.net.PlainSocketImpl2.create(PlainSocketImpl2.java:59)
W/System.err( 164): at java.net.Socket.checkClosedAndCreate(Socket.java:763)
W/System.err( 164): at java.net.Socket.connect(Socket.java:910)
W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.
W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:800)
W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:786)
W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1030)
[/code]
add this permission to your android manifest file
[code]
[/code]
References:
http://code.google.com/android/devel/security.html#permissions
http://code.google.com/android/reference/android/Manifest.permission.html#INTERNET
Τετάρτη 4 Φεβρουαρίου 2009
Always native look & feel
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
from http://www.dimitrisk.gr/blog/?p=8
Πέμπτη 18 Δεκεμβρίου 2008
Java Generics
http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
pdf tutorial
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
Τρίτη 9 Δεκεμβρίου 2008
Subclipse
Subclipse is an Eclipse Team Provider plug-in providing support for Subversion within the Eclipse IDE. The software is released under the Eclipse Public License (EPL) 1.0 open source license.
Παρασκευή 21 Νοεμβρίου 2008
HashMap tutorial
http://www.javadeveloper.co.in/java-example/java-hashmap-example.html
Τετάρτη 19 Νοεμβρίου 2008
Βγήκε η έκδοση 6.5 του Netbeans!
Κατεβάστε την απο εδώ: http://www.netbeans.org/downloads/
Μερικά features:
* The award-winning NetBeans IDE for Java keeps getting better. New to 6.5: support for Groovy and Grails, built-in support for Hibernate, Eclipse project import, Compile/Deploy on Save, and much more.
* Value Proposition: We continue to build on our award-winning IDE for Java by adding popular new features and improvements. Find out why NetBeans IDE for Java is the right IDE for you- with rich support for ME/SE/EE development and new feature highlights including Groovy and Grails support, built-in support for Hibernate, Eclipse project import/synchronization, Compile/Deploy on Save, and Ajax-enabled JSF CRUD generator.
* Simplify your Python development with the NetBeans IDE for Python- Early Access. This community driven project combines the practical development expertise of Python developers with the experience of IDE development by the NetBeans community.
* Developers can enjoy great editor features such as code completion, semantic highlighting, instant rename, smart indentation, pair matching, and more. The EA release also includes a community developed Python debugger as well as the ability to choose between the Python and Jython runtimes.
Packaging a Java application on Debian
http://www.debian.org/doc/packaging-manuals/java-policy/index.html
Πέμπτη 16 Οκτωβρίου 2008
Using Streams in Java
Using Java Streams: http://docs.rinet.ru/WebJPP/ch13.htm
Input and Output Streams: http://www.iam.ubc.ca/guides/javatut/java/io/index.html
Basic I/O: http://java.sun.com/docs/books/tutorial/essential/io/
Very very fast:
* Byte Streams handle I/O of raw binary data.
* Character Streams handle I/O of character data, automatically handling translation to and from the local character set.
* Buffered Streams optimize input and output by reducing the number of calls to the native API.
* Scanning and Formatting allows a program to read and write formatted text.
* I/O from the Command Line describes the Standard Streams and the Console object.
* Data Streams handle binary I/O of primitive data type and String values.
* Object Streams handle binary I/O of objects.
Δευτέρα 6 Οκτωβρίου 2008
Calculate the execution time
private long start;
private long end;
//Put this before the main code
start = System.currentTimeMillis();
//Main code here
//Put this at the end of the code
end = System.currentTimeMillis();
System.out.println("Completed in +"+(end-start)+"ms");
Running a threadless application on a Intel Core2 CPU
cat /proc/cpuinfo
ventrix@bytemobile:~$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz
stepping : 6
cpu MHz : 1875.766
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
I created an application to test if a number is prime or not. It isn't very special, except the fact that you can check REALLY big numbers...
The result is this:

As you can see with htop, only one of the cores is executing the application.
Also, if you take a careful look at the xfce's cpu meter, the total use of the CPU counts a 50% percent.
After 25 minutes I guess 170141183460469231731687303715884105727 IS a big number to test:)
[BTW 170141183460469231731687303715884105727 is a prime, according to http://en.wikipedia.org/wiki/List_of_prime_numbers)
Τετάρτη 17 Σεπτεμβρίου 2008
Java comments for javadoc how to
In Netbeans, write /** before a constructor for example and press enter. It will automatically generate the javadoc comments for that constructor!
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
*
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
http://java.sun.com/j2se/javadoc/writingdoccomments/
Πέμπτη 4 Σεπτεμβρίου 2008
J2me sockets and streams...
a call to Connector.open("sockets://...") in the main thread will STOP your application from running without an error.
if the inputStream is blocked waiting for a read(), then the outputStream is blocked also.
a call to InputStream.available() always returns 0, regardless of how many bytes are actually available.
Τρίτη 2 Σεπτεμβρίου 2008
Java Naming Conventions
http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html
http://geosoft.no/development/javastyle.html
