Friday, March 6, 2009

Reading custom field from Manifest file in JAVA

Hi EveryOne,


If your PM tell you declare a version number for your application.
And if you declared application version number as constant in source code.

Then what happens when your application update and version number should be change?

What will you do, again change in source code, then compile, then create jar etc?

It is not just a case where your constant need to update.

i have a solution.

Just add a field on manifest file. And read these fields from your code.
Here i am putting a example code to do so.

It is very easy. You can read all fields from manifest.

For source code see below.

/*

* Program for reading a field from manifest file

* Copyright 2009 @ yuvadeveloper

* Code By:- Prashant Chandrakar

*

* */

import java.io.*;

import java.util.*;

import java.util.jar.*;

import java.net.*;

public class JarRead

{

public static void main(String[] args) throws Exception

{

new JarRead().call();

}

public void call()

{

try

{

////pass your jar file name which included manifest file

JarFile jf = new JarFile("CDViewer.jar");

////getting manifest file from jar file

Manifest m = jf.getManifest();

////getting all attribute from manifest file

Attributes attr = m.getMainAttributes();

////taking values from manifest file.

////existing field

String SOFTWARE_VERSION = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION); // 2.0

String SOFTWARE_VENDOR = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR); // YuvaDevelopers Pvt.Ltd.

String SOFTWARE_VENDOR_TITLE = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE); // ManifestReader

////custom defined field

String dType = attr.getValue("RunType");

System.out.println(SOFTWARE_VERSION + "\n" + SOFTWARE_VENDOR + "\n" + SOFTWARE_VENDOR_TITLE + "\n" + dType);

}

catch(Exception e)

{

System.out.println(e);

}

}

}

Manifest file:-

Manifest-Version: 1.2
Main-Class: JarRead
Created-By: 1.4 (Sun Microsystems Inc.)
Specification-Title: build57
Specification-Version: 1.0
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: Manifest Reader
Implementation-Version: 1.0.0
Implementation-Vendor: YuvaDevlopers Pvt.Ltd.
RunType: Customfield

Just save as manifest.mf file and add while creating jar file.

Wednesday, March 4, 2009

Secure your class files in JAVA


Hello Friends,
     As you seen in my previous post, there I had posted too many tools that re-engineer  your class files.

So today's java developer most worried question is how to secure class files to become reverse Engineering.

Don't Worry friends,
There are too many tools to protect your class files.

There are many methods to protect your class files.
  1. Obfuscator
  2. Manglers
  3. jar To Executer
Obfuscator:-

      The technique behind Obfuscator is they encode your class files with certain encryption algorithm and while execution your application they again decoded or decrypted.

So other than obfuscator know body knows which encryption algorithm is used for encoding so you are unable to decode the class files.

I have used many of them and believe me they are very good.



6. Jcloak

7. JODE

8. Zelix Klass Master

9. Marvin

10. ProGuard

11. RetroGuard

12. Shroudit

13. Smokescreen

14. Saffeine

15. Code Shield

16. Java Guard

17. yGuard

18. Jobfuscator

19. Jasob

20. Crema
      Not found
21. Hashjava
      Not found
22. Allatori
http://www.allatori.com/

Manglers:- 
    
          There are also some Manglers available which mangle your class
files code. It is also protect your classes but up to certain limit. 
It applies the technique of mangling function, variable names, class 
names, interface name etc.

Below is the list of Manglers.

Jar To Exe :-

         Just make a jar file from your class files.
And make exe file from your jar file.For creating exe from jar files please refer my previous post there i had posted number of tools for that.

        

Tuesday, March 3, 2009

Java Decompilers (.class to .java file)

Hello friends,


Its a very sensational news for all who dont know how to convert .class files to .java files or decompilation of class files.

Sometime we need to decompile our class files back to java source files.
So which are the tools available?

Don't worry friends probably i have list of all the decompilers available in market.

If i forget any tool or you have any idea other than these please share with me.
I test many of the tools and some of having certain limitation.

See below is the list of all the decompilers.
The first three are very demanded in market and they are very good too.

1. JODE

2. Mocha

4. cavaj

6. SourceTech

13. Jasmine Decompiler
http://www.jreveal.org/

16. JADClipse

18. javad

===============================================
      Online Tools
-----------------------------------------------------------------------------------

19. Online DEC
http://www.tigernt.com/tools/Java/index.shtml?

===============================================
Old Tools (May Link Broken)
------------------------------------------------------------------------------------

20. JAD
http://www.kpdus.com/jad/winnt/jadnt158.zip

22. DejaVu
23. class Spy
24. NMI

Monday, March 2, 2009

Convert JAR files to EXE

Hello Everyone,


The most worried things in java world is how to save your code from decoding.
  
As you all know that there are certain tools which decode or convert your .class file code to .java files.

So how can you save your code.Solution is make a exe or Executable for windows user.
 
If you want for window OS then here i am listing all the tool for converting jar files to exe Executable.

These tools are also used for deployment purpose or setup maker.
I used many of them and they are superb.
  

1. Excelsior JET

2. JSmooth
6. IzPack

7. JExecreater

8. ExeJ

9. Executer

10. Jar2Exe

11. Advace Installer

12. JExePack

13. Xenoage

14. NativeJ

 15. JNC


Saturday, February 28, 2009

Layout Managers in JAVA

Hi friends,


While setting Layout in JAVA application, everyone is just
thinking of some common layouts. They are...
  1. FlowLayout
  2. BorderLayout
  3. GridLayout
  4. GridBagLayout
  5. Card Layout
  6. Null Layout or Absolute Positioning.
But they all are belongs to Java.awt.classes

But Swing introduces some of very new and intresting types of
layouts.
They are...
  1. BoxLayout
  2. GroupLayout
  3. OverlayLayout
  4. SpringLayout
  5. ScrollPaneLayout
  6. ViewPortLayout
So friends here i am discussing about all.