Monday, January 18, 2010

mod_xsendfile compiling in mac os x leopard and snow leopard for i386 or x86_64 arch type

Mod_Xsendfile is a small Apache2 module that processes X-SENDFILE headers registered by the original output handler."

If you did encountered trouble integrating the module for XSendfile for Apache in Mac OS X, I manage to compile it by passing the flags which would suffice the architecture of the processor's model.

apxs -cia -Wc,"-arch x86_64" -Wl,"-arch x86_64" mod_xsendfile.c

-Wc          the compiler flags
-Wl           the linker flags.


That is applicable only if your arch type is x86_64 in Mac. I have Snow Leopard in my desktop, priorly it was Leopard 10.5.8.

For Leopard 10.5.8, It does works when you pass "-arch i386" for compiler flags and linker flags. This works like a charm and Apache doesn't end up segmentation fault anymore.

Hope this helps!

Sunday, January 17, 2010

Java - make a jar file and include external classes or jar files, creating keystore, and signing a jar app

Compiling java app


D:\java_apps\myapp>javac -verbose -sourcepath src_code_dir -classpath extlib\jai-1_1_4-pre-dr-b03-lib-windows-i586-28_Sep_2009\lib\ext\jai_codec.jar;"C:\Program Files\Java\jre6\lib\plugin.jar"; -d sod sod\org\myapp\ScanDriverApplet.java

-d               destination directory for class files
-verbose         includes information about each class loaded and each source 
                 file compiled.
-classpath       Set the user class path, overriding the user class path in the
                 CLASSPATH environment variable. If neither CLASSPATH or 
                 -classpath is specified, the user class path consists 
                 of the current directory. See Setting the Class Path for more 
                 details.


                 If the -sourcepath option is not specified, the user class path
                 is searched for source files as well as class files.

Creating a keystore


D:\java_apps\myapp>keytool -keystore mykeystorefilename -genkey -alias myappalias

-keystore       The keystore (database file) location. Defaults to the file .keystore in the user's home directory, as determined by the "user.home" system property, whose value is described inKeystore Location.
-genkey        Generates a key pair (a public key and associated private key)
-alias             alias will be used to

Results to:
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  My Sample Inc.
What is the name of your organizational unit?
  [Unknown]:  My Sample Inc.
What is the name of your organization?
  [Unknown]:
What is the name of your City or Locality?
  [Unknown]:
What is the name of your State or Province?
  [Unknown]:
What is the two-letter country code for this unit?
  [Unknown]:
Is CN=My Sample Inc., OU=My Sample Inc., O=Unknown, L=Unknown, ST=Unknown, C
=Unknown correct?
  [no]:  yes


Enter key password for
        (RETURN if same as keystore password):

D:\java_apps\myapp>



Creating a jar file


D:\java_apps\my_app>jar -cvfe ../myapp.jar -C org


-C     Temporarily changes directories (cd dir) during execution of the jar command while processing the following inputfiles argument. Its operation is intended to be similar to the -C option of the UNIX tar utility. For example:


jar uf foo.jar -C classes bar.class
would change to the classes directory and add the bar.class from that directory to foo.jar. The following command,
jar uf foo.jar -C classes . -C bin xyz.class
would change to the classes directory and add to foo.jar all files within the classes directory (without creating a classes directory in the jar file), then change back to the original directory before changing to the bin directory to add xyz.class to foo.jar. If classes holds files bar1 and bar2, then here's what the jar file would contain using jar tf foo.jar:
META-INF/
META-INF/MANIFEST.MF
bar1
bar2
xyz.class



Signing a jar app: This avoid "Unable to create temporary file" and permission issues, while running applet...

D:\java_apps\my_app>jarsigner -keystore mykeystorefilename myapp.jar myappalias
Results to: 
Enter Passphrase for keystore:

Warning:
The signer certificate will expire within six months.


The file size of the jar file will be updated.