Friday, June 14, 2013

FreeMarker: An open alternative to JSP

Today I read a good article about FreeMarker - an alternative to JSP: http://www.javaworld.com/jw-01-2001/jw-0119-freemarker.html?page=1

Some notes about performance which I were looking for:

- Much like JSP, FreeMarker compiles templates to improve runtime performance. Those templates are stored in memory in a format that leaves placeholders for dynamic data. The controller fills those placeholders with dynamic data from the model. For this purpose, the controller must have access to both the model and the view. Once the dynamic data is retrieved from the model, the controller will print the template to a given output stream.
- Once templates are compiled, you can process them in parallel, leading to a significant performance boost.

- For anything other than the most trivial projects, FreeMarker provides a TemplateCache interface, implementations of which act as a repository for precompiled templates.

- An additional feature of TemplateCache objects is that they automatically reload templates when the template source file has changed. That relieves you of having to start and stop the servlet engine when you need to make changes to the HTML.

JSP versus FreeMarker (official documentation): http://freemarker.sourceforge.net/docs/app_faq.html#faq_jsp_vs_freemarker

Wednesday, June 5, 2013

Debugging JavaScript in Chrome

Let's have test.html:

<html>
  <head>
   <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
   <script type="text/javascript" src="fun.js"></script>
  </head>
  <body>
   <button onclick="return simpleFunction();">Click me</button>
   <ul id="testId"></ul>
  </body>
</html>


and fun.js:

function simpleFunction() {
  for (var i=0; i < 7; i++) {
   var html = '<li>' + i + '</li>';
   $('#testId').append(html);
  }
  return false;
}



Wednesday, May 22, 2013

Unsupported major.minor version 51.0

Today I faced with the following exception:

java.lang.UnsupportedClassVersionError: com/rdiachenko/blackbox/alg/InsertionSortTest : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Reason: Java sources were compiled with JDK 7, but were running on the lower JDK 6.
Solution: use higher (or the same) JDK during runtime and lower (or the same) during compile time.

Verstion 51.0 in exception message means J2SE 7. Here the list of all versions: http://en.wikipedia.org/wiki/Java_class_file

Wednesday, May 15, 2013

JavaScript plugin for Eclipse

Found a nice plugin for Eclipse which provides a pretty handy work with JavaScript - VJET.

VJET JavaScript IDE is an Eclipse plugin that provides a fully integrated development environment for JavaScript. Its main features:

- Code Assistance
- Code Search
- Syntax and Semantic Checking
- Type Declarations using VJETDoc
- Execution/Debugging

The project's site is here: http://www.eclipse.org/vjet/
The update site is here: http://www.eclipse.org/vjet/download/

Install and run Windows applications on Fedora/Ubuntu

PlayOnLinux is a tool which allows to install/run Windows applications under Linux. It is a kind of shell for wine.



Installation for Fedora:

$ wget http://rpm.playonlinux.com/playonlinux.repo
$ sudo cp  playonlinux.repo /etc/yum.repos.d/
$ sudo yum install playonlinux

Installation for Ubuntu here

Thursday, February 28, 2013

SSH log-in without entering the password

1. If you have no public and private ssh keys run the following command and press Enter for all the input requests:

$ ssh-keygen

2. Copy your public key to the remote server you want to log-in to via ssh without entering the password:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@remote_host

3. Try to log-in to the server without entering the password:

$ ssh username@remote_host

Tuesday, December 4, 2012

Run multiple Skypes under linux

In order to run several Skypes there should be a separate skype config folder in your home directory for each skype process.

$ mkdir ~/.Skype_1
$ skype --dbpath=~/.Skype_1 &

$ mkdir ~/.Skype_n
$ skype --dbpath=~/.Skype_n &

Tuesday, May 8, 2012

C++: First steps on Fedora

Install compiler, autoconf and automake tools:

$ sudo yum install gcc gcc-c++ autoconf automake

autoconf - a tool for producing configure scripts for building, installing and packaging software on computer systems where a Bourne shell is available [1];

automake - a programming tool that produces portable makefiles for use by the make program, used in compiling software [2];

GNU GCC C compiler (gcc)  - the package contains a GNU Compiler Collection;

GNU GCC C++ compiler (gcc-c++) - the package adds C++ support to the GNU Compiler Collection [3].

$ man g++

gcc - GNU project C and C++ compiler
...
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage.  For example, the -c option says not to run the linker.  Then the output consists of object files output by the assembler.
...

Friday, April 13, 2012

Configure FTP server on Fedora 16/17

This post is about the configuration of FTP server for the specified users.

$ sudo yum install vsftpd
$ sudo nano /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
ftpd_banner=Welcome to FTP server!!
chroot_local_user=YES
listen=NO
log_ftp_protocol=YES
max_per_ip=5 # Max number of allowed connections per IP Address.
max_clients=5 # Max number of different IP Addressed which are allowed to connect.
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES


Wednesday, April 11, 2012

Install Lexmark Z600 printer driver on Fedora 16/17

$ sudo yum install glibc-2.* cups-libs-1.5.* compat-libstdc++-33.i686 popt.i686 cups-libs.i686

Download CJLZ600LE-CUPS-1.0-1.TAR.gz.

$ tar xvzf CJLZ600LE-CUPS-1.0-1.TAR.gz
$ export _POSIX2_VERSION=199209
$ tail -n +143 z600cups-1.0-1.gz.sh > install.tar.gz
$ tar -xvzf install.tar.gz
$ sudo rpm -ivh z600cups-1.0-1.i386.rpm z600llpddk-2.0-1.i386.rpm
$ sudo systemctl restart cups.service


 Add the printer using the Lexmark Z600 driver in System > Administration > Printing.

Source: http://heuristically.wordpress.com/2010/12/03/install-lexmark-x1150-printer-driver-fedora/