tag:blogger.com,1999:blog-78089362067392765812024-03-13T08:18:19.686-07:00Ventrix JavaCheck http://ventrix.nsdc.gr/code_folds/
This is just a temporary reference...Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-7808936206739276581.post-17819609983408485642009-03-27T06:03:00.000-07:002009-03-27T06:04:40.779-07:00JPA implementations comparison: Hibernate, Toplink Essentials, Openjpa, EclipselinkJPA implementations comparison: Hibernate, Toplink Essentials, Openjpa, Eclipselink <br /><br />http://terrazadearavaca.blogspot.com/2008/12/jpa-implementations-comparison.htmlVentrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-32513806300225010382009-03-20T04:37:00.000-07:002009-03-20T04:39:06.287-07:00Eclipse ShortcutsEclipse Shortcuts<br /><br />Just press Ctrl + Shift + L !<br /><br />http://www.allapplabs.com/eclipse/eclipse_shortcuts.htm<br /><br />http://codeofdoom.com/wordpress/2009/03/05/favorite-eclipse-shortcuts/Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-36464970943858715592009-03-06T10:10:00.000-08:002009-03-06T10:18:53.721-08:00ΗμερολόγιοΑύριο (7/3/09) έχουμε και λέμε:<br /><span style="font-weight:bold;">10.00</span>: <span style="font-style:italic;"><span style="font-weight:bold;">Γενική Συνέλευση & Κοπή Πίττας Hellug</span></span><br /><br />Τετάρτη (11/3/09) έχουμε και λέμε:<br /><span style="font-weight:bold;">19:00</span>: <span style="font-style:italic;"><span style="font-weight:bold;">Παρουσίαση Android στο PLUG</span></span>Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-78727310680097160652009-02-27T13:29:00.001-08:002009-02-27T13:33:56.516-08:00J2ee Start a class when application server startsIf you want to start a class when your application server starts, you simply have to follow two steps:<br /><br />1) create a new class that implements ServletContextListener.<br />then implement the two methods: contextInitialized(ServletContextEvent event) and contextDestroyed(ServletContextEvent event).<br /><br />example:<br /><p class="command">public final class MyContextListener implements<br /> ServletContextListener {<br /><br /> public void contextInitialized(ServletContextEvent event) {<br /><br /> /* This method is called when the servlet context is<br /> initialized(when the Web Application is deployed).<br /> You can initialize servlet context related data here.<br /> */<br /> MainThread mainthread1 = new MainThread();<br /> mainthread1.start();<br /> }<br /><br /> public void contextDestroyed(ServletContextEvent event) {<br /><br /> /* This method is invoked when the Servlet Context<br /> (the Web Application) is undeployed or<br /> WebLogic Server shuts down.<br /> */<br /><br /> System.out.println("goodbye");<br /> //thread's clean up code<br /> }<br />}</p><br /><br />Then add:<br /><p class="command"><listener><listener-class>Tools.MyContextListener</listener-class></listener></p><br />under the web-app of web.xml file.<br /><br />That's it!Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-64755061511272869952009-02-25T06:23:00.000-08:002009-02-25T06:29:23.747-08:00Android get Screen orientationYou can check your screen orientation by calling:<br />[code]int orientation = getWindowManager().getDefaultDisplay().getOrientation()[/code]<br />and checking if it equals on of the following...<br /><br />Configuration.ORIENTATION_PORTRAIT<br />Configuration.ORIENTATION_LANDSCAPE<br />...Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-15757281735600408992009-02-23T08:23:00.000-08:002009-02-23T08:35:03.566-08:00Eclipse line break [wrap]<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.incoras.com/%5Cincoras%5Cimages%5Ceclipse.jpg"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 246px; height: 162px;" src="http://www.incoras.com/%5Cincoras%5Cimages%5Ceclipse.jpg" alt="" border="0" /></a><br />Καλό χρυσό όμορφο το eclipse, αλλά ο formater του μου έσπαγε τα νεύρα όταν "δίπλωνε" τις γραμμές στον κώδικα κατα το source formating λες και δούλευα σε 13'' οθόνη...<br /><br />Μετά απο αρκετό καιρό, μια καλή ημέρα (σήμερα) αποφάσισα να το ψάξω λίγο περισσότερο και να βρω μια λύση.<br /><br />Έχουμε και λέμε λοιπόν:<br />Windows -> Preferences -> Java -> Code Style -> Formatter -> Edit -> Maximum line width.<br /><br />Επίσης για αυτούς που δεν θέλουν ΚΑΘΟΛΟΥ wrapping, μπορούν να το αλλάξουν, πειράζοντας το πεδίο "Line wrapping policy" σε Do not wrap.<br /><br />Do not wrap my code λοιπόν bitch!Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-11818800830790893652009-02-14T09:27:00.000-08:002009-02-14T09:32:41.060-08:00Android unknown socket error -1Exception:<br />[code]E/OSNetworkSystem( 164): unknown socket error -1<br />W/System.err( 164): java.net.SocketException: unknown error<br />W/System.err( 164): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl(Native Method)<br />W/System.err( 164): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocket(OSNetworkSystem.java:79)<br />W/System.err( 164): at org.apache.harmony.luni.net.PlainSocketImpl2.create(PlainSocketImpl2.java:59)<br />W/System.err( 164): at java.net.Socket.checkClosedAndCreate(Socket.java:763)<br />W/System.err( 164): at java.net.Socket.connect(Socket.java:910)<br />W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:61)<br />W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)<br />W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)<br />W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:800)<br />W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:786)<br />W/System.err( 164): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1030)<br />[/code]<br /><br />add this permission to your android manifest file<br />[code]<manifest xmlns:android="http://schemas.android.com/apk/res/android"<br /> package="com.android.app.myapp" ><br /><br /> <uses-permission name="android.permission.INTERNET"><br /><br /></manifest>[/code]<br /><br />References:<br />http://code.google.com/android/devel/security.html#permissions<br />http://code.google.com/android/reference/android/Manifest.permission.html#INTERNETVentrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-33756218242645643232009-02-04T08:01:00.000-08:002009-02-04T08:02:31.875-08:00Always native look & feeltry {<br />UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName());<br />} catch (Exception e) {<br />}<br /><br />from http://www.dimitrisk.gr/blog/?p=8Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-43037731920481456822008-12-18T02:52:00.001-08:002008-12-18T02:52:58.774-08:00Java GenericsJava Generics<br />http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html<br /><br />pdf tutorial<br />http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdfVentrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-30558984890170073392008-12-09T07:51:00.001-08:002008-12-09T07:51:47.978-08:00Subclipse<a href="http://subclipse.tigris.org">http://subclipse.tigris.org/</a><br /><br />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.Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-28281758071413704952008-11-21T07:30:00.001-08:002008-11-21T07:30:52.278-08:00HashMap tutorialA very simple but still great hashmap tutorial:<br /><a href=" http://www.javadeveloper.co.in/java-example/java-hashmap-example.html"><br />http://www.javadeveloper.co.in/java-example/java-hashmap-example.html</a>Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-10636038956122850292008-11-19T15:44:00.000-08:002008-11-25T00:42:57.795-08:00Βγήκε η έκδοση 6.5 του Netbeans!Βγήκε η έκδοση 6.5 του Netbeans!<br /><br />Κατεβάστε την απο εδώ: <a href="http://www.netbeans.org/downloads/">http://www.netbeans.org/downloads/</a><br /><br />Μερικά features:<br /> * 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.<br /> * 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.<br /> * 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.<br /> * 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.<br /><br /><a href="http://www.sync.gr/claim/GHmgNkP4V1B9" rel="sync"></a>Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-45990717448318609322008-11-19T02:11:00.000-08:002008-11-19T02:15:01.423-08:00Packaging a Java application on DebianBefore packaging your Java program on Debian, be sure you have read the Debian policy for Java, located here:<br /><br />http://www.debian.org/doc/packaging-manuals/java-policy/index.htmlVentrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-84702504870215454132008-10-16T01:00:00.000-07:002008-10-16T01:03:56.883-07:00Using Streams in JavaIf you got confused by the number of streams in Java, check this out:<br /><br />Using Java Streams: http://docs.rinet.ru/WebJPP/ch13.htm<br /><br />Input and Output Streams: http://www.iam.ubc.ca/guides/javatut/java/io/index.html<br /><br />Basic I/O: http://java.sun.com/docs/books/tutorial/essential/io/<br /><br />Very very fast:<br /><br />* Byte Streams handle I/O of raw binary data.<br />* Character Streams handle I/O of character data, automatically handling translation to and from the local character set.<br />* Buffered Streams optimize input and output by reducing the number of calls to the native API.<br />* Scanning and Formatting allows a program to read and write formatted text.<br />* I/O from the Command Line describes the Standard Streams and the Console object.<br />* Data Streams handle binary I/O of primitive data type and String values.<br />* Object Streams handle binary I/O of objects.Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-34459054058358949302008-10-16T00:57:00.000-07:002008-10-16T00:59:15.823-07:00Ventrix's Code FoldsVentrix's Code Folds<a href="http://ventrix.nsdc.gr/code_folds/" rel="external"><img src="http://ventrix.nsdc.gr/advisory-explicit_code.jpg" alt="Explicit code" width="200"></a>Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-15519415539025471722008-10-06T04:53:00.000-07:002008-10-06T04:55:14.552-07:00Calculate the execution time//variables<br />private long start;<br />private long end;<br /><br />//Put this before the main code<br />start = System.currentTimeMillis();<br /><br />//Main code here<br /><br />//Put this at the end of the code<br />end = System.currentTimeMillis();<br /><br />System.out.println("Completed in +"+(end-start)+"ms");Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-76065345569515889042008-10-06T03:15:00.000-07:002008-10-06T03:27:58.477-07:00Running a threadless application on a Intel Core2 CPUMy processor:<br /><p class="command"><br />cat /proc/cpuinfo<br /><br />ventrix@bytemobile:~$ cat /proc/cpuinfo <br />processor : 0<br />vendor_id : GenuineIntel<br />cpu family : 6<br />model : 15<br />model name : Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz<br />stepping : 6<br />cpu MHz : 1875.766<br />cache size : 2048 KB<br />physical id : 0<br />siblings : 2<br />core id : 0<br />cpu cores : 2<br /></p><br /><br />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...<br /><br />The result is this:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs2hBC3vspwGuYvaZiZWQc0-YdIwp9wqYfrpPE1znKrOox8yAirLT_19yUzWXLV1c1OuboQhNwBZ157AKdfighbN4Gzy4v9xWjCTFsKT44seN4S3bySORIjgZf-bLxvKe8I4yweVHFqN8O/s1600-h/no-threads11.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs2hBC3vspwGuYvaZiZWQc0-YdIwp9wqYfrpPE1znKrOox8yAirLT_19yUzWXLV1c1OuboQhNwBZ157AKdfighbN4Gzy4v9xWjCTFsKT44seN4S3bySORIjgZf-bLxvKe8I4yweVHFqN8O/s320/no-threads11.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5253985158657087298" /></a><br /><br />As you can see with htop, only one of the cores is executing the application.<br />Also, if you take a careful look at the xfce's cpu meter, the total use of the CPU counts a 50% percent.<br /><br />After 25 minutes I guess 170141183460469231731687303715884105727 IS a big number to test:)<br />[BTW 170141183460469231731687303715884105727 is a prime, according to http://en.wikipedia.org/wiki/List_of_prime_numbers)Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-59213996084861323842008-09-17T05:51:00.000-07:002008-09-17T06:57:34.548-07:00Java comments for javadoc how toJava comments for javadoc how to<br /><br />In Netbeans, write /** before a constructor for example and press enter. It will automatically generate the javadoc comments for that constructor!<br /><br /><p class="command"><br />/**<br /> * Returns an Image object that can then be painted on the screen. <br /> * The url argument must specify an absolute {@link URL}. The name<br /> * argument is a specifier that is relative to the url argument. <br /> * <p><br /> * This method always returns immediately, whether or not the <br /> * image exists. When this applet attempts to draw the image on<br /> * the screen, the data will be loaded. The graphics primitives <br /> * that draw the image will incrementally paint on the screen. <br /> *<br /> * @param url an absolute URL giving the base location of the image<br /> * @param name the location of the image, relative to the url argument<br /> * @return the image at the specified URL<br /> * @see Image<br /> */<br /> public Image getImage(URL url, String name) {<br /> try {<br /> return getImage(new URL(url, name));<br /> } catch (MalformedURLException e) {<br /> return null;<br /> }<br /> }<br /></p><br /><br />http://java.sun.com/j2se/javadoc/writingdoccomments/Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-43722414058908489542008-09-04T04:02:00.000-07:002008-09-04T04:03:30.739-07:00J2me sockets and streams...http://www.russellbeattie.com/notebook/1002646.html<br /><br />a call to Connector.open("sockets://...") in the main thread will STOP your application from running without an error.<br /><br />if the inputStream is blocked waiting for a read(), then the outputStream is blocked also.<br /><br />a call to InputStream.available() always returns 0, regardless of how many bytes are actually available.Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-45761753444842787212008-09-02T02:38:00.001-07:002008-09-02T02:38:48.769-07:00Java Naming ConventionsJava Naming Conventions<br /><br />http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html<br /><br />http://geosoft.no/development/javastyle.htmlVentrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-15667493033825914212008-08-27T06:52:00.000-07:002008-08-27T06:53:10.527-07:00Parsing XML String using DOMhttp://www.albeesonline.com/blog/2007/10/09/parsing-xml-string-using-dom/Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-90759734298832322492008-08-27T02:37:00.000-07:002008-08-27T02:43:55.224-07:00Java Persistence API Getting StartedJPA - Java Persistence API<br /><br />Ένα πολύ καλό Getting Started εδώ: http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40ff8a3d-065a-2910-2f84-a222e03d1f43<br /><br />τόσο καλό που το έκανα mirror εδώ: http://ventrix.nsdc.gr/stuff/Getting_Started_Java_Persistence_Api.pdf<br /><br />Και μετά ελέγξτε και αυτό: https://glassfish.dev.java.net/javaee5/persistence/persistence-example.htmlVentrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-19013381644459721342008-08-12T02:30:00.000-07:002008-08-27T02:53:47.189-07:00Threads in J2MEA really good article to get started at:<br /><br />http://developers.sun.com/mobility/midp/articles/threading2/<br /><br />And always remember:<br /><br />When creating a thread, we implement the run() BUT call the start() method.Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-89832600555498784952008-07-02T03:36:00.000-07:002008-07-02T03:38:50.354-07:00Java to exe, JSmooth a Java Executable WrapperJSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself.<br /><br />When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a web site.<br /><br />JSmooth provides a variety of wrappers for your java application, each of them having their own behaviour: Choose your flavour! <br /><br />http://jsmooth.sourceforge.net/Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0tag:blogger.com,1999:blog-7808936206739276581.post-70935622382339789802008-06-11T03:06:00.000-07:002008-06-11T03:16:28.873-07:00Creating jar applicationsΑφού κάνουμε compile τα αρχεία .java ώστε να παραχθούν τα .class εκτελούμε μέσα στον φάκελο την εξής εντολή:<br />jar cvfm test.jar manifestfile *.class<br /><br />ώστε να δημιουργηθεί το jar αρχείο test.jar το οποίο θα περιέχει το manifest αρχείο manifestfile και όλα τα .class. Αν έχετε και άλλα αρχεία που θέλετε να περιλαμβάνει μπορείτε να τα προσθέσετε και αυτά δίπλα στο *.class χωρίζοντας τα με κενό.<br /><br />Το αρχείο mainfestfile πρέπει να περιέχει τα εξής:<br /><br />Manifest-Version: 1.2<br />Main-Class: mainclass<br />Created-By: 1.4 (Sun Microsystems Inc.)<br /><br />Όπου mainclass το όνομα (χωρίς την κατάληξη) της main κλάσης του προγράμματος.<br /><br />Για να το τρέξετε πατήστε:<br />java -jar example.jar (σε linux)<br />ή<br />C:\Java\jdk1.4.0\bin\javaw.exe -jar example.jar (σε windows)Ventrixhttp://www.blogger.com/profile/10642081693642977478noreply@blogger.com0