29 April, 2010 - 10:29 am
Tags: Class, Java, method, programming, Reflection
Posted in english | 1 comment
import java.lang.reflect.*; public class Foo { public void bar(int param){ System.out.println(param); } public static void main(String args[]){ Object f = new Foo(); try { Method m = f.getClass().getMethod("bar", int.class); m.invoke(f, 42); } catch (Exception e){ System.err.println(e); } } } $ java Foo 42
8 April, 2010 - 1:09 pm
Tags: getruntime, Java, programming, runtime
Posted in english | No comments
I don’t like the approach of calling native shell commands in any language instead of using multi platform libraries, but here is a little prof of concept Java program to call native commands. import java.io.*; import java.util.*; public class Exec { public static void main(String args[]) throws IOException { Process proc = Runtime.getRuntime().e xec(args); BufferedReader [...]
Iterating over a HashMap using the enhanced loop (foreach) in Java is a good way to keep your code smaller, more legible and usually more semantically coherent. import java.util.HashMap; import java.util.Map; class Foo {} public class Main { public static void main(String args[]){ Map<Byte, Foo> mHash; mHash = new HashMap<Byte, Foo>(); [...]
18 March, 2010 - 12:00 am
Tags: Android, branch, cmd, git, programming
Posted in english | 1 comment
Getting the Android’s AlarmClock application source from official repositories: git clone git://android.git.kernel.org/platform/packages/apps/AlarmClock.git To get the head version for an old platform like the 1.4 (codename donut), choose the correspondent branch using -o or –origin: git clone git://android.git.kernel.org/platform/packages/apps/AlarmClock.git –origin donut
This is a simple program I wrote called Who Am I that shows informations about the device which it is running. Which can be useful for developers and maybe advanced users. Download: WhoAmI.tar.bz2 – Eclipse project. It’s configured for Android platform 4 (1.6) but should work without problems in newer Android platform versions. WhoAmI.apk – [...]
27 February, 2010 - 9:39 pm
Tags: caps lock, Java, programming, socket, upcase
Posted in english | 1 comment
Here is a simple server for those who are starting studying sockets or just needs a simple socket server example for reuse while writing your own behavior. Features: A client should enter a string and the server would answer the same string, with each symbol in up case, when possible. Default port at 8080. One [...]
22 February, 2010 - 5:16 pm
Tags: development, i18n, Java, JUnit, locale, programming, String, teste unitário, toString, unit testing
Posted in english | No comments
Today I was programming a toString method for a class widely used in a application, using the very useful String.format that provides a C’s like printf formatter. @Override public String toString() { return String.format("VO[a: %.1f, b: %.1f, c: %.1f]", a, b, a+b); } %.1f means a float with one digit precision after the dot separator. [...]
O pre-requisito é o notify-send, um utilitário de linha de comando do libnotify. No Ubuntu: sudo aptitude install libnotify-bin E aqui o script em si: sleep 5m; notify-send “aviso” “tirar o miojo do fogo” Pronto, depois de cinco minutos isso vai aparecer:
20 January, 2010 - 10:55 pm
Tags: date, datetime, ISO 8601, Jochen Voss, Markus Kuhn, programming, Python, representation, sort, sorting, time
Posted in english | No comments
I was looking for a date and time representation useful for registering stock quotes in a simple plain file. I found that the standard ISO 8601 is just the answer for this, it’s called “Data elements and interchange formats — Information interchange — Representation of dates and times”. Here is a example: 2010-01-20 22:14:38 There’s this [...]
5 January, 2010 - 6:10 pm
Tags: AWT, fonts, Java, JVM, Larabie, Larabie Fonts, programming
Posted in english | Comments Off
Here’s a program that lists fonts available in your JVM. You can also set the environment variable JAVA_FONTS to specify the font directory. import java.awt.GraphicsEnvironment; public class ListFonts { public static void main(String args[]){ GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); for(String font:e.getAvailableFontFamilyNames()){ System.out.println(font); } } } By using pipes you can count how many fonts you [...]
11 June, 2008 - 10:16 am
Error in syntactic analysis in temp.fx:
java.lang.ArrayIndexOutOfBoundsException: -1
at org.antlr.runtime.Parser.getMissingSymbol(Parser.java:62)
at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:624)
at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:117)
at com.sun.tools.javafx.antlr.v3Parser.module(v3Parser.java:289)
at com.sun.tools.javafx.antlr.JavafxSyntacticAnalysis.parse(JavafxSyntacticAnalysis.java:70)
at com.sun.tools.javafx.main.JavafxCompiler.parse(JavafxCompiler.java:478)
at com.sun.tools.javafx.main.JavafxCompiler.parse(JavafxCompiler.java:519)
at com.sun.tools.javafx.main.JavafxCompiler.parseFiles(JavafxCompiler.java:825)
at com.sun.tools.javafx.main.JavafxCompiler.compile(JavafxCompiler.java:665)
at com.sun.tools.javafx.main.Main.compile(Main.java:597)
at com.sun.tools.javafx.main.Main.compile(Main.java:304)
at com.sun.tools.javafx.Main.compile(Main.java:84)
at com.sun.tools.javafx.Main.main(Main.java:69)
11 June, 2008 - 2:37 pm
@Vinay right is this moment JavaFX language are passing by some changes and getting better. Unfortunately this made mostly of my codes posted here not parseable using NetBeans JavaFX plugin.
For running them you should find out the JavaFX Pad and past this code there.
30 July, 2008 - 5:38 am
wow,so clean code and so effective~
16 September, 2008 - 9:22 am
toyv xmsodt enoswiv
16 September, 2008 - 11:06 am
jyrs
18 September, 2008 - 8:34 am
nzdy
20 September, 2008 - 1:09 pm
gzsexu sqtyw umsd ivkwha
6 December, 2008 - 3:25 am
JavaFX 1.0 is released, do you have a plan to rewrite your code to the latest syntax? That will be very helpful for people. Thanks.
19 March, 2009 - 2:12 am
opa ! estou com uma nova versao dos cabecudinhos,
muitas novidades !!!
http://www.athanazio.com/2009/03/19/javafx-os-cabecudinhos-preview-2009-03-18/
abs