Friday, 18 July 2008

Java Community Process (JCP) membership

According to Wikipedia: "The Java Community Process or JCP, established in 1998, is a formalized process which allows interested parties to be involved in the definition of future versions and features of the Java platform."

Since its introduction, JCP has played a very important role as an open process to define the future of Java. It is the place where JSR (Java Specification Request) are discussed, and this is the reason why is so important to be part of it: you can help improve Java collaborating, giving contributions and new ideas before any feature become available or definitive.

I became a JCP member just a few days ago. I hope I can give my contribution, but I am sure I will learn much more than I will teach.

My name is there :P, check here (it is listed according to your last surname. Mine is "Silva").

Please take a look at JCP's site: jcp.org

Monday, 7 July 2008

Como configurar vino remotamente via ssh no ubuntu 8.04

Hi, everybody. A friend of mine suggested me to write some Portuguese posts. This is the first one. I will try to write in both languages always that this is possible (I mean: always I have time to do it :P).

Pessoal,

Hoje tive que configurar o acesso remoto por VNC a uma máquina rodando o ubuntu tendo acesso a ela apenas através do SSH. Isso é útil quando não há ninguém na frente da máquina que você está querendo acessar para clicar no pop-up que autoriza o acesso remoto via VNC, por exemplo.

Você pode configurar qualquer uma das opções, basta saber o nome delas. Para isso, há duas alternativas: o gconftool-2 ou alterar o arquivo de configuração usando um editor de texto qualquer.
  • Opção 1:
Habilitar o acesso remoto:
shell> gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled true

Eliminar a necessidade de confirmação pelo usuário que está na frente do computador:
shell> gconftool-2 -s -t bool /desktop/gnome/remote_access/prompt_enabled false

Setar a senha desejada (opcional):
shell> gconftool-2 -s -t string /desktop/gnome/remote_access/vnc_password `senha_desejada`

  • Opção 2 (editar o arquivo de configuração):
Faça um backup de segurança do arquivo:
shell> cp .gconf/desktop/gnome/remote_access/%gconf.xml .gconf/desktop/gnome/remote_access/%gconf.xml.back


Abra o arquivo e inclua, remova ou edite as opções que precisar:
shell> vi .gconf/desktop/gnome/remote_access/%gconf.xml



O arquivo usa sintaxe xml e as propriedades são setadas assim:
<entry name="nome_da_propriedade" mtime="1215460375" type="bool" value="true">

O nome da propriedade é igual ao passado pelo comando gconftool-2, o mtime é um timestamp da propriedade, type é o tipo (normalmente bool ou string) e value o valor.

Importante: lembre-se que senhas e pedidos de autorização são procedimentos de segurança importantes. Se você precisar desabilitá-los momentaneamente para algum procedimento, volte a habilitá-los assim que for possível, evitando dores de cabeça.

Sim, eu sei que há outras maneiras de fazer a mesma coisa. Essa é apenas uma alternativa para considerar quando for necessário fazer esse tipo de procedimento.

Tuesday, 1 July 2008

Java and scripting languages

This is a very popular topic since JVM has provided scripting language support. There lots of blogs and articles talking about this topic and many people excited about this feature. But others are a bit sceptical about it. I am part of the second group.

I agree that scripting support adds some flexibility to Java platform development, undoubtly. But I can't see it as a "solution for all your problems" like a lot of people are saying around internet. I think it is a good tool for specific problems. You can use it to solve a problem that you know is easier to solve using that script language you love. But there are shortcomes if you want to use it in a larger scope than that very specific task. I mean: "ok, lets use it, but this is only a nice feature, useful in specific circunstances".

If you want to try scripting capabilities inside your java program, this is the easiest way:
  1. Create a ScriptEngineManager object.
  2. Get a ScriptEngine object from the manager.
  3. Evaluate the script using the ScriptEngine's eval methods.

import javax.script.*;

public class EvalScript {
public static void main(String[] args) throws Exception {
// create a script engine manager
ScriptEngineManager factory = new ScriptEngineManager();
// create a JavaScript engine
ScriptEngine engine = factory.getEngineByName("JavaScript");

// create a Java object
String name = "Tom";

// create the binding
engine.put("greetingname", name);

// evaluate JavaScript code from String
engine.eval("println('Hello, ' + greetingname)");
engine.eval("println('The name length is ' + greetingname.length)");
}
}

You can use Rhino, Quercus, Scala, JRuby, JavaFX, JavaScript and almost any scripting language, including your own language (scripting support is pluggable, so you can write a component to support your own language).

Don't use scripting in a performance critical part of your application and always try to use intermediary result, to boost performance (some languages support intermediary compilation, increasing performance).

You can see more at Java Scripting Programmer's Guide, and this article (the example came from there).