Posts in java

How to get user locale in a Java Servlet

septiembre 30th, 2010 Posted by java, locale, servlet 0 thoughts on “How to get user locale in a Java Servlet”

Locale locale = request.getLocale();
Enumeration locales = request.getLocales();

appengine hot deploy on mac

septiembre 29th, 2010 Posted by appengine, google, gwt, java 0 thoughts on “appengine hot deploy on mac”

1. Install JRebel
2. In Eclipse go to Help -> Install New Software… and download JRebel plugin http://www.zeroturnaround.com/update-site
3. Specified jrebel.jar jar in Eclipse / JRebel.
4. Modify dev_appserver.sh and let it something like this:

java -ea -cp “$JAR_FILE”
com.google.appengine.tools.KickStart
–jvm_flag=-javaagent:$REBEL_HOME/jrebel.jar –jvm_flag=-noverify
com.google.appengine.tools.development.DevAppServerMain $*

5. Add to the Run Configuration this VM Argument

-javaagent:/path/to/jrebel/jrebel.jar -noverify

6. Now it must works!

Taken from this steps for Windows http://androidisland.blogspot.com/2010/09/appengine-jrebel-and-eclipse-getting.html

Cómo utilizar Quartz con Tomcat

julio 8th, 2010 Posted by java, quartz, tomcat 0 thoughts on “Cómo utilizar Quartz con Tomcat”

1. Bajar Quartz desde http://www.quartz-scheduler.org/ y poner el .jar en el classpath

2. Poner esto en el web.xml


QuartzInitializer
org.quartz.ee.servlet.QuartzInitializerServlet
shutdown-on-unload true
2

How to set an id to a GWT TextBox

junio 22nd, 2010 Posted by gwt, java 0 thoughts on “How to set an id to a GWT TextBox”

TextBox myTextBox = new TextBox();
myTextBox.getElement().setId(“my_text_box_id”);

Get Unix Time in Java

junio 22nd, 2010 Posted by java, time, unix 0 thoughts on “Get Unix Time in Java”

return (int) (System.currentTimeMillis() / 1000L);

Jerarquía de niveles de debug en log4j

junio 17th, 2010 Posted by java 0 thoughts on “Jerarquía de niveles de debug en log4j”

Log4j provee al programador de 5 niveles de debug:

* OFF, no se muestra en ningún caso
* FATAL, para mostrar mensajes de situaciones que probablemente harán abortar la aplicación
* ERROR, para mostrar mensajes de errores que no son deseados pero que no interrumpirán la aplicación
* WARN, para mostrar mensajes de contextos peligros para la aplicación, o ciertas operaciones de uso no recomendado
* INFO, para mostrar mensajes de información sobre la ejecución de la aplicación, o eventos importantes dentro de la misma
* DEBUG, para mostrar mensajes interesantes para depurar la aplicación. Muy orientado al tiempo de desarrollo
* ALL, se muestra en todos los casos

Cómo crear directorios en Java

junio 10th, 2010 Posted by dir, java 0 thoughts on “Cómo crear directorios en Java”

import java.io.*;
class CreateDirectory
{
public static void main(String args[])
{
try{
String strDirectoy =”test”;
String strManyDirectories=”dir1/dir2/dir3″;

// Create one directory
boolean success = (new File(strDirectoy)).mkdir();
if (success) {
System.out.println(“Directory: ” + strDirectoy + ” created”);
}

// Create multiple directories
success = (new File(strManyDirectories)).mkdirs();
if (success) {
System.out.println(“Directories: ” + strManyDirectories + ” created”);
}

}catch (Exception e){//Catch exception if any
System.err.println(“Error: ” + e.getMessage());
}
}
}

Cómo generar un zip en java

junio 10th, 2010 Posted by java, zip 0 thoughts on “Cómo generar un zip en java”

public static Boolean generateZipFile(String[] filenames, String outFilename){
// Create a buffer for reading the files
byte[] buf = new byte[1024];

try {
// Create the ZIP file
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
// Compress the files
for (int i=0; i
FileInputStream in = new FileInputStream(filenames[i]);
// Add ZIP entry to output stream.
out.putNextEntry(new ZipEntry(filenames[i]));
// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
// Complete the entry
out.closeEntry();
in.close();
} // Complete the ZIP file
out.close();

return true;
} catch (IOException e) {
return false;
}
}

Que es Ant (JAVA)?

enero 13th, 2009 Posted by java 0 thoughts on “Que es Ant (JAVA)?”

Es una herramienta para Open Source utilizada para la creación y compilación de programas (similar al make de Linux.) Java. Está escrito en Java y XML.

Copyright © 2018 programadorfreelanceargentina.com

Programador Freelance Argentina