Tuesday, 23 December 2014

what is the difference between JAVA SE and EE

Differences between Java EE and Java SE

Java technology is both a programming language and a platform. The Java programming language is a high-level object-oriented language that has a particular syntax and style. A Java platform is a particular environment in which Java programming language applications run.
There are several Java platforms. Many developers, even long-time Java programming language developers, do not understand how the different platforms relate to each other.

The Java Programming Language Platforms

There are four platforms of the Java programming language:
  • Java Platform, Standard Edition (Java SE)
  • Java Platform, Enterprise Edition (Java EE)
  • Java Platform, Micro Edition (Java ME)
  • JavaFX
All Java platforms consist of a Java Virtual Machine (VM) and an application programming interface (API). The Java Virtual Machine is a program, for a particular hardware and software platform, that runs Java technology applications. An API is a collection of software components that you can use to create other software components or applications. Each Java platform provides a virtual machine and an API, and this allows applications written for that platform to run on any compatible system with all the advantages of the Java programming language: platform-independence, power, stability, ease-of-development, and security.

Java SE

When most people think of the Java programming language, they think of the Java SE API. Java SE's API provides the core functionality of the Java programming language. It defines everything from the basic types and objects of the Java programming language to high-level classes that are used for networking, security, database access, graphical user interface (GUI) development, and XML parsing.
In addition to the core API, the Java SE platform consists of a virtual machine, development tools, deployment technologies, and other class libraries and toolkits commonly used in Java technology applications.

Java EE

The Java EE platform is built on top of the Java SE platform. The Java EE platform provides an API and runtime environment for developing and running large-scale, multi-tiered, scalable, reliable, and secure network applications.

Java ME

The Java ME platform provides an API and a small-footprint virtual machine for running Java programming language applications on small devices, like mobile phones. The API is a subset of the Java SE API, along with special class libraries useful for small device application development. Java ME applications are often clients of Java EE platform services.

JavaFX


JavaFX is a platform for creating rich internet applications using a lightweight user-interface API. JavaFX applications use hardware-accelerated graphics and media engines to take advantage of higher-performance clients and a modern look-and-feel as well as high-level APIs for connecting to networked data sources. JavaFX applications may be clients of Java EE platform services.

Thursday, 25 September 2014

Java Heap Memory error

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:1585)
    at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1409)
    at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2886)
    at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:476)
    at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2581)
    at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1757)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2171)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2512)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1476)
    at DBase.connect(automateExport.java:31)
    at automateExport.main(automateExport.java:10)
Answer:

When you query returns very large sets, the mysql driver will by default load the entire result set in memory before giving you control back. It sounds like you're just running out of memory, so increase the memory furter, e.g. -Xmx1024M
The other alternative might be to enable streaming results on your MySQL queries- this prevents the entire ResultSet to be loaded into memory all at once. This can be done by doing
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, 
           java.sql.ResultSet.CONCUR_READ_ONLY);//These are defaults though,I believe
stmt.setFetchSize(Integer.MIN_VALUE);

Friday, 13 June 2014

Why We Use Web Services?


Ø AS Web Services are some Piece of code, there is chance of exposing the functionality of a service over a network. By this Other Applications can Use these Functionalities.

Ø By using Web Services different types of Applications can communicate each other.


Ø It Uses Wide variety of Protocol stack so that  there is somany advantages like wide range of choices and reduction in Cost.

Ø It uses simple and cost Effective protocols like SOAP,HTTP etc.


Ø Besides these also uses many protocols if necessary.

Ø Use variety of technologies to implement web services and these are self explanatory.


Ø It automatically discovers the service providers near by it and starts communicate.

Ø New services can easy to Enter and starts their business.


Web services are mixture of HTTP, XML that convert it to web applications and share these to rest of the World.
It consists of elements like Http, SOAP, WSDL.

Thursday, 12 June 2014

How to upload a file in blogger for download?

Upload a file and direct Download from blog

  When you need to Upload a small file into Web and share with your followers without leaving them from your blog to another hosting file for Download a file.How can i ?Read the Scenario , A Adobe Photoshop Designer Needs to Share his source file(PSD file format) of his Image to his Followers of his Blog.He don't need to Leave them his Blog into Hosting Site that contains malicious ads.


   Go to       https://sites.google.com    and Create a New site.

    
   Now Create a page in File Cabinet.
  

    






After Click on "Add File" and Browse the File and Upload it.
After Uploading the Image , Right Click on "Download" and select "Copy the Link Address"


Go Back to Blogger Post and Tyep "Download File "and Make Link into copied Link address.



    How to zip a file with password using java?



    You can do this one by using the

    sevenzipjbinding.jar and winzipaes-
    20100321.jar

    You can down load the jars by clicking the below link






    You can copy the Code and  Execute the code Directly by Adding the Jars to Classpath

    Service Class:

     import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import de.idyl.crypto.zip.AesZipFileEncrypter;

    public class ZipUtil {

    public static void zipDirWithPassword( String dirName , String zipFileName , String password)
    {
    if( zipFileName == null )
    {
    File tempFile = new File(dirName);
    zipFileName = tempFile.getAbsoluteFile().getParent() +File.separator+tempFile.getName()+".zip";
    }
    zipDir(dirName, zipFileName);
    String tempZipFileName = new File( dirName ).getAbsoluteFile() .getParent()+File.separator+"tempencrypted.zip";
    try
    {
    AesZipFileEncrypter enc = new AesZipFileEncrypter (tempZipFileName);
    enc.addEncrypted( new File(zipFileName), password);
    new File(zipFileName).delete();
    new File( tempZipFileName ).renameTo( new File (zipFileName));
    }
    catch (IOException e) 
    {
    e.printStackTrace();
    }
    }//method ZipWith Password
    public static void zipDir( String dirName , String zipFileName )
    {
    if( zipFileName == null )
    {
    File tempFile = new File(dirName);
    zipFileName = tempFile.getAbsoluteFile().getParent()+ File.separator+tempFile.getName()+".zip";
    }
    try 
    {
    ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFileName));
    compressDir(dirName, zos, new File(dirName).getName()+File.separator);
    zos.close();
    }
    catch( NullPointerException npe )
    {
    npe.printStackTrace();
    }
    catch (FileNotFoundException e)
    {
    e.printStackTrace();
    }
    catch( IOException ie )
    {
    ie.printStackTrace();
    }
    }//Method zipDir
    private static void compressDir(String directory, ZipOutputStream zos, String path) throws IOException {
    File zipDir = new File(directory);
    String[] dirList = zipDir.list();
    byte[] readBuffer = new byte[2156];
    int bytesIn = 0;
    for (int i = 0; i < dirList.length; i++) 
    {
    File f = new File(zipDir, dirList[i]);
    if (f.isDirectory()) 
    {
    String filePath = f.getPath();
    compressDir(filePath, zos, path + f.getName() + "/");
    continue;
    }
    FileInputStream fis = new FileInputStream(f);
    try 
    {
    ZipEntry anEntry = new ZipEntry(path + f.getName());
    zos.putNextEntry(anEntry);
    bytesIn = fis.read(readBuffer);
    while (bytesIn != -1)
    {
    zos.write(readBuffer, 0, bytesIn);
    bytesIn = fis.read(readBuffer);
    }
    }
    catch( Exception e )
    {
    e.printStackTrace();
    }
    finally 
    {
    fis.close();
    }
    }
    }// Method CompressDir


    }//Class



    Main Class:



    public class MainClass 
    {


    public static void main(String[] args)
    {
    ZipUtil.zipDirWithPassword("F:/ZipaFolderUsingPassword/ZipaDirectoryUsingPassword/inputFiles","F:/ZipaFolderUsingPassword/ZipaDirectoryUsingPassword/ZipFolder/zipfile.zip", "abcd1234");



    }//main method

    }//class