Error while compiling java file using J2SE 1.5.0

Dear Sir,
I'm getting the following error while compiling the java file.The code is also given.
package test;
public class TestRowSet {
public TestRowSet() {
"TestRowSet.java": cannot access java.lang.Object,bad class file: D:\Program Files\Java\jdk1.5.0\jre\lib\rt.jar\java\lang\Object.class,class file has wrong version 49.0, should be 48.0,Please remove or make sure it appears in the correct subdirectory of the classpath. at line 4, column 1
Please help me out.
--Suketu Naik.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

But I'm compiling within "Borland JBuilder 9.0". I've
set the JDK path of the current project to point to
the path of JDK 1.5.0 . I've also tried to compile at
command prompt with "javac". I'm getting the same
error of "Undefinedclassloader" with long StatckTrace.
I don't know anything about JBuilder either. If you use the command prompt and enter the full path to the 1.5 javac.exe then that will prove whether the issue is using an older javac or not. For example "c:\j2sdk1.5.0_01\bin\javac HelloWorld.java"

Similar Messages

  • Error while compiling java file

    Hi, im newby in java,
    i was trying to compile java files, and after that i will use it in JSP as javabean.
    I have 2 files already, the first file is a connection code, and its compiled successfully, it looks like this
    i named this as ConnectionBean.java
    package my_package;
    import java.sql.*;
    public class ConnectionBean {
         private Connection con;
         private static final String driver = "org.postgresql.Driver";
         private static final String url = "jdbc:postgresql://localhost:5432/PSQLDS";
         private static final String username = "postgres";
         private static final String password = "mypassword";
         public ConnectionBean() {
         public Connection logOn() {
              try {
                   Class.forName(driver); con = DriverManager.getConnection(url, username, password); }
              catch(ClassNotFoundException e) {
                   System.err.println("ConnectionBean: driver unavailable..."); con = null; }
              catch (SQLException e) {
                   System.err.println("ConnectionBean: driver not loaded..."); con = null; }
              return con;
         public void logOff() {
              try {
                   con.close(); }
              catch (Exception e) {
                   e.printStackTrace(); }
    as you can see above im using "package", and yes i have manage to put all my java files within the correct path (ROOT\WEB-INF\classes\my_package)
    And also, i have test this class as javabean on JSP file and it works.
    There for i continue to create the second java file, as a purpose to create a back engine for JSP. I use the same package as ConnectionBean.java, it looks like this
    i named this as ListPageEngine.java
    package my_package;
    import java.beans.*;
    import java.sql.*;
    public class ListPageEngine {
         public static void main(String[] args) {
              ConnectionBean conBean = new ConnectionBean();}
    on compiling process using command "javac ListPageEngine.java", i get this error message
    ListPageEngine.java:11: cannot find symbol
    symbol : class ConnectionBean
    location: class my_package.ListPageEngine
    ConnectionBean conBean = new ConnectionBean();}
    ^
    ListPageEngine.java:11: cannot find symbol
    symbol : class ConnectionBean
    location: class my_package.ListPageEngine
    ConnectionBean conBean = new ConnectionBean();}
    ^
    2 errors
    I think, i am pretty much sure that all my configuration (wheater its Apache TomCat, Environment Variable or PostgreSQL server) was good, as a prove, i was able to use ConnectionBean.class in my JSP file.
    I susspect the problem is related with "package", seems i cannot use ConnectionBean class within ListPageEngine class when i use package.
    For another information, i didn't install such thing as J2EE, i only install JDK 1.5, i also guess this might be the cause.
    Right now im all stuck, i try to find thread which might be related with my problem but i failed to find it, most of them get the same answer by UncleSAM which are
    Try the following forum (about JSP technology)
    http://forum.java.sun.com/forum.jspa?forumID=45
    JavaBeans spec contains nothing about JSP, but JSP spec describes using of beans.
    i hope my question is clear so anyone who might have experience or clue with this problem might be able to help me.
    Thanks before

    finally folks, i found answer to my own problem hehehehe..
    the problem is on the compiling command (javac ... my_file.java), i found that i need to add some parameter on the command to make it works.
    This problem solved.

  • Error while loading java file in Oracle

    Hi,
    I am facing error while loading java class into oracle . Can you please help
    -bash-3.2$ cd /export/home/sacuser/
    -bash-3.2$ loadjava -user sacuserdb/sacuserdb@BLM - resolve Oracle_Validator/src/com/nec/blm/oracle/validator/Validate.java
    unrecognized or badly formed option -
    loadjava: Usage: loadjava [-definer] [-encoding encoding] [-force] [-genmissing] [-genmissingjar jar] [-grant grant                                          s] [-help] [-nousage] [-noverify] [-oci8] [-order] [-resolve] [-resolver resolver] [-schema schema] [-synonym] [-th                                          in] [-tableschema schema] [-user user/password@database] [-verbose] classes..jars..resources..properties...
    -bash-3.2$ loadjava -user sacuserdb/sacuserdb@BLM -resolve Oracle_Validator/src/com/nec/blm/oracle/validator/Validate.java
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : 11 occurred at PC=0x0
    Function=[Unknown.]
    Library=(N/A)
    NOTE: We are unable to locate the function name symbol for the error
          just occurred. Please refer to release documentation for possible
          reason and solutions.
    Current Java thread:
            at oracle.jdbc.driver.T2CConnection.t2cCreateState(Native Method)
            at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:346)
            at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:413)
            at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:131)
            at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:77)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752)
            at java.sql.DriverManager.getConnection(DriverManager.java:512)
            - locked <0xf5fdc448> (a java.lang.Class)
            at java.sql.DriverManager.getConnection(DriverManager.java:140)
            - locked <0xf5fdc448> (a java.lang.Class)
            at oracle.aurora.server.tools.loadjava.DatabaseOptions.getConnection(DatabaseOptions.java:180)
            at oracle.aurora.server.tools.loadjava.DatabaseOptions.connect(DatabaseOptions.java:123)
            at oracle.aurora.server.tools.loadjava.LoadJavaState.getConnection(LoadJavaState.java:409)
            at oracle.aurora.server.tools.loadjava.LoadJavaState.getOldMD5(LoadJavaState.java:696)
            at oracle.aurora.server.tools.loadjava.ClientSchemaObject.getOldMD5(ClientSchemaObject.java:52)
            at oracle.aurora.server.tools.loadjava.SchemaObject.doCreate(SchemaObject.java:172)
            at oracle.aurora.server.tools.loadjava.SchemaObject.process1(SchemaObject.java:215)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:532)
            at oracle.aurora.server.tools.loadjava.LoadJava.addSource(LoadJava.java:574)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:439)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:380)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:349)
            at oracle.aurora.server.tools.loadjava.LoadJava.add(LoadJava.java:652)
            at oracle.aurora.server.tools.loadjava.LoadJava.processDeferredFiles(LoadJava.java:617)
            at oracle.aurora.server.tools.loadjava.LoadJava.process(LoadJava.java:818)
            at oracle.aurora.server.tools.loadjava.LoadJava.command(LoadJava.java:251)
            at oracle.aurora.server.tools.loadjava.LoadJavaMain.run(LoadJavaMain.java:103)
            at oracle.aurora.server.tools.loadjava.LoadJavaMain.main(LoadJavaMain.java:28)
    Dynamic libraries:
    0x8050000       /opt/oracle/product/10g/jdk/jre/bin/java
    0xfef80000      /lib/libthread.so.1
    0xfef40000      /lib/libdl.so.1
    0xfee10000      /lib/libc.so.1
    0xfea00000      /opt/oracle/product/10g/jdk/jre/lib/i386/client/libjvm.so
    0xfedd0000      /usr/lib/libCrun.so.1
    0xfedb0000      /lib/libsocket.so.1
    0xfe960000      /lib/libnsl.so.1
    0xfed90000      /lib/libm.so.1
    0xfedc0000      /usr/lib/libsched.so.1
    0xfe900000      /lib/libm.so.2
    0xfed40000      /lib/libscf.so.1
    0xfe8e0000      /lib/libdoor.so.1
    0xfe8b0000      /lib/libuutil.so.1
    0xfe890000      /lib/libgen.so.1
    0xfe870000      /lib/libmd.so.1
    0xfe850000      /lib/libmp.so.2
    0xfe830000      /opt/oracle/product/10g/jdk/jre/lib/i386/native_threads/libhpi.so
    0xfe3d0000      /opt/oracle/product/10g/jdk/jre/lib/i386/libverify.so
    0xfe3a0000      /opt/oracle/product/10g/jdk/jre/lib/i386/libjava.so
    0xfe380000      /opt/oracle/product/10g/jdk/jre/lib/i386/libzip.so
    0xf9e80000      /opt/oracle/product/10g/lib32/libocijdbc10.so
    0xf0e00000      /opt/oracle/product/10g/lib32/libclntsh.so.10.1
    0xf0c60000      /opt/oracle/product/10g/lib32/libnnz10.so
    0xf9e60000      /lib/libkstat.so.1
    0xf9e30000      /lib/libaio.so.1
    0xf1b60000      /lib/librt.so.1
    Heap at VM Abort:
    Heap
    def new generation   total 576K, used 237K [0xf1e00000, 0xf1ea0000, 0xf22e0000)
      eden space 512K,  45% used [0xf1e00000, 0xf1e3a058, 0xf1e80000)
      from space 64K,   8% used [0xf1e90000, 0xf1e915c0, 0xf1ea0000)
      to   space 64K,   0% used [0xf1e80000, 0xf1e80000, 0xf1e90000)
    tenured generation   total 1408K, used 204K [0xf22e0000, 0xf2440000, 0xf5e00000)
       the space 1408K,  14% used [0xf22e0000, 0xf23130f0, 0xf2313200, 0xf2440000)
    compacting perm gen  total 4096K, used 2662K [0xf5e00000, 0xf6200000, 0xf9e00000)
       the space 4096K,  65% used [0xf5e00000, 0xf6099a38, 0xf6099c00, 0xf6200000)
    Local Time = Mon Jun 17 16:29:08 2013
    Elapsed Time = 0
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.4.2_05-b04 mixed mode)
    # An error report file has been saved as hs_err_pid27805.log.
    # Please refer to the file for further information.
    Abort (core dumped)

    Please try to compile your java source file with jdk avaiable in ORACLE_HOME\jdk\bin\javac.
    load the compiled class file in oracle DB using loadjava utility.
    loadjava -user scott/tiger javafile.class

  • Error while compile .Java to .class

    I am new in java card. I have some problem when compile java card applet.
    1. I installed j2sdk1.4.2_07 and java_card_kit- 2_2_2 to build a sample java card. I set the environment as:
    @echo off
    set JC_HOME=C:\java_card_kit-2_2_2-windows\java_card_kit-2_2_2
    set JAVA_HOME=c:\j2sdk1.4.2_07
    set PATH=.;%JC_HOME%\bin;%JAVA_HOME%\bin;%PATH%
    I created a java applet and saved in C\STCard, and I use windows command to compile, the command is:
    c:\java_card_kit-2_2_2-windows\java_card_kit-2_2_2\samples>javac -g -classpath c:\STCard;..\lib\api.jar;..lib\installer.jar c:\STCard\*.java
    but the error is: "cannot access javacard.framework.APDU"
    What am I wrong?
    2. I use eclipse 3.3.2, eclipse jcde 0.1, java_card_kit-2_2_2, jdk1.6.0 to compile java card applet. The compilation from .java to .class was no problem, but from the .class to .cap has problem:
    java com.sun.javacard.converter.Converter -config .\converter2.opt
    error: stcard.STCard: unsupported class file format of version 50.0.
    What should I do to convert from .class to .cap?
    Thx all

    I have a typically problem , I am a student and learning core java am just a beggineer in java,i have sucessfully installed my JavaEE1.5 software on my computer but have got a problem while compiling my Java programs ,while passing the commands in my command prompt i am encounteering a problem ,am geeting an error message in my command prompt" 'javac' is not recoginized as an internal or external command ,operable program or batch file".i had also tried my own software cd of JavaEE1.5 version and installed at others computers it is running sucessfully but can i know Why it is not geeting in to my Pc & giving compilation error while compiling my java programs. so kindly sujjest me my remedy of my problem.

  • How to compile Java files using Ant in Eclipse

    Hi All ,
    I would like to compile all Java files using Ant in Eclipse.Since am very new to Ant and Eclipse can someone help me to create a build.xml file and let me know how to compile all the java files.
    For ex , I have placed my java files inside the path C:\HEC\Terab.Initially the Terab folder holds 7 jar files which i had decompiled using JD compiler and placed the unzipped 7 folders (which contains the java files ).Now i have imported the HEC project into Eclipse using New ->Project ->Java Project.after importig it throwed me an error saying missing jar files.again i copied the jar files and placed inside Terab folder with other 7 folder.
    Now How i can compile the java files and convert in to class files.Then after compiling the files i will again need to jar all the 7 folder.
    Please tell me the steps i need to follow.How to write an build.xml file ? where i should keep it ? only one build.xml file is enough or should i write 7 build.xml file for each folder ? Please help me out...
    Thanks & Regards
    Kar1983

    put it another way, what I am trying to do is to compile David Brackeen's ch 18 code from his book. The java sourse files can be downloaded here:
    http://www.brackeen.com/javagamebook/
    my question is that how would I complie all of these file so that I can get the program in ch18src\src\com\brackeen\javagamebook\test\ to run?

  • Error while creating logical file using transaction FILE

    Hello there,
    I am facing an error while creating Logical File name definition using transaction FILE
    This is the input which I'm trying to give
    Logical file name: ZTEST
    Name : ZTEST
    Physical file : ZTEST_1<DATE><TIME>.csv
    Data format: ASC
    Application area: BW
    Logical path:ZTEST_1_DATAOUT
    when I tried to save it throws me an error like  ASSIGN_SUBSTRING_NOT_ALLOWED
    Please help.

    Hi,
    Please check the OSS Notes :
    Note 792061 - SP Case Locator: Dump: ASSIGN to a substring isn't allowed.
    SAP Note 1297989 - Short dump ASSIGN_SUBSTRING_NOT_ALLOWED
    Hope this solves the problem.
    -Vikram

  • Error while compiling SOA composite using Jdeveloper

    Hi,
    I am getting below given error while compiling the SOA composite using Jdeveloper..
    I m referring this PDF to develop a custom workflow.
    http://st-curriculum.oracle.com/obe/fmw/oim/oim_11g/developing_oim_custom_approval_process_for_self_registration/developing_oim_custom_approval_process_for_self_registration.pdf
    Error(45,34): Failed to compile bpel generated classes.
    failure to compile the generated BPEL classes for BPEL process "ApprovalProcess" of composite "default/SelfRegistrationApproval!1.0"
    The class path setting is incorrect.
    Ensure that the class path is set correctly. If this happens on the server side, verify that the custom classes or jars which this BPEL process is depending on are deployed correctly. Also verify that the run time is using the same release/version.
    Can u please let me know what am I missing here.
    Regards,
    Ab

    Hi,
    If u have any custom jars..make sure to add them at SCA-INF/lib directory.
    Thanks,

  • Error while saving xml file using PDFDocument API

    Hi,
    I am trying to save xml file using byte array obtained from interactive form element in webdynpro java.
    The file gets saved but I get fllowing error message when I open the file.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    An invalid character was found in text content. Error processing resource 'http://uxjciesk.wdf.sap.corp:50000/irj/go/km/doc...
    The code I am trying to achieve the functionality is:
    byte[] byteArray  = wdContext.currentContextElement().getPdfSource();
    IWDPDFDocumentHandler pdfDocumentHandler = WDPDFDocumentFactory.getDocumentHandler();
    IWDPDFDocumentAccessibleContext documentAccessibleContext = pdfDocumentHandler.getDocumentAccessibleContext();
    documentAccessibleContext.setPDF(byteArray);
    IWDPDFDocument pdfDocument = documentAccessibleContext.execute();
    ByteArrayInputStream dataInputStream = (ByteArrayInputStream) pdfDocument.getPDFAsStream();
    further, the datainputstream is used to store the file. I am able to save same xdp template in pdf file format successfully, the error only occurs for xml file storage.
    Please, advise.
    Regards,
    Urvashi

    Hi Urvashi,
        Try this code
              String contentStr = getXMLData(wdContext.currentContextElement().getPdfSource().read(false));
              String data = "";
              ByteArrayOutputStream pdfSourceOutputStream = new ByteArrayOutputStream();
              try {
                   InputStream pdfSourceInputStream = wdContext.currentContextElement().getData().read(false);
                   BufferedInputStream bufferedInputStream = new BufferedInputStream(wdContext.currentContextElement().getData().read(false));
                   int aByte;
                   while ((aByte = bufferedInputStream.read()) != -1) {
                        pdfSourceOutputStream.write(aByte);
                   pdfSourceOutputStream.flush();
                   pdfSourceOutputStream.close();
                   IWDPDFDocument pdfDocument = null;
                   try {
                        // Create an instance for PDFDocumnetHandler
                        IWDPDFDocumentHandler pdfDocumentHandler = WDPDFDocumentFactory.getDocumentHandler();
                        //Create an Inatance for PDFDocumentAccessibleContext
                        IWDPDFDocumentAccessibleContext documentAccessibleContext =     pdfDocumentHandler.getDocumentAccessibleContext();
                        //set the pdf data as OutputStream to the PDFDocumentAccessibleContext instance
                        documentAccessibleContext.setPDF(pdfSourceOutputStream);
                        //call the server to get the data                      
                        pdfDocument = documentAccessibleContext.execute();
                        //get the xml data in a InputStream
                        ByteArrayInputStream dataInputStream = (ByteArrayInputStream) pdfDocument.getData();
                   } catch (Exception e) {
                        data = "Null";
              } catch (IOException e) {
    Regards,
    Mathan

  • Error while accessing excel file using ODBC

    Hi
    I am getting the below error message while accessing excel sheet using ODBC from Oracle:
    ERROR at line 1:
    ORA-28545: error diagnosed by Net8 when connecting to an agent
    Unable to retrieve text of NETWORK/NCR message 65535
    ORA-02063: preceding 2 lines from EXCL
    Can anyone help me on this...
    Cheers
    Pradeep
    Message was edited by:
    user634393

              Hi
              Thank you.Is there a way to read a file which is existing in the war file.
              Regards
              Anand Mohan
              "Wenjin Zhang" <[email protected]> wrote:
              >
              >In Weblogic, if your files are archived in a WAR, you cannot get an entry
              >as individual
              >file since it is only bytes in a large archive file. So getRealPath will
              >give
              >you null result. If you only want the path, try to use other getXXXPath,
              >getURL,
              >or getURI method. If you want to read the content, use getResource.
              >
              >
              >"Anand" <[email protected]> wrote:
              >>
              >>Hi
              >>I am having problem while accessing the file located in the server from
              >>a JSP
              >>page. I am not getting the RealPath from a JSP page using getRealPath(request.getServletpath()).
              >>
              >>The same code is working if the jsp placd under defaultwebApp directory
              >>and not
              >>working if i create a war and deploy the same.
              >>
              >>I am using weblogic server 7.0 trail version.I am setting the context
              >>path also.
              >>
              >>Can any help me in this regard.
              >>
              >>Thank And Regards
              >>
              >>Anand Mohan
              >
              

  • Error while Building Jar files using [ejbc]

    Hi,
    I am building EJB's using [ant ejbc] for upgrade from Weblogic 6.1 to Weblogic 10.0. The code gets build fine but when creating the Jar file it is throwing me the following error :-
    [ejbc] Loading properties file: /C:/dev/MarketingOne/thirdparty/sms/lib/logging.//config/logging.properties
    [ejbc] SMS_ERROR:
    [ejbc] Properties:
    [ejbc] - Failed to load properties file: /C:/dev/MarketingOne/thirdparty/sms/lib/logging.//config/logging.properties
    [ejbc] java.io.FileNotFoundException: C:\dev\MarketingOne\thirdparty\sms\lib\logging.\config\logging.properties (The system cannot find the path specified)
    [ejbc] - Either invalid SMS_HOME: /C:/dev/MarketingOne/thirdparty/sms/lib/logging./ or invalid <I>SERVICE</I>_P
    ROPERTIES_FILE_NAME
    [ejbc] at java.io.FileInputStream.open(Native Method)
    [ejbc] please set SMS_HOME using -D option at JVM start up.
    Can anybody provide me with a solution for this as the path mentioned for SMS Logging.properties file is correct..??

    Actually the folder 'lib' consists of a logging Executable Jar file and the SMS folder consists of 'config' and 'lib' folders. Inside the 'config folder is a logging.properties file.
    But Actually I am not getting any idea as to from where this command is being triggered because my targets.xml file does not have any such command whereas it just builds all the files and then creates the jar file.
    Is it a problem of using EJB 2.0 in Weblogic 10.0 environment or jdk1.5..??

  • Error while deploying war file using JRUN JMC

    Hi,
    I am getting "Deployment service failed to deploy war file" Error
    while trying to deploy a war file using JRUN Mgmt console.
    If anyone has any idea about it, please help.
    Thanks
    Jit

    Check the logs. There might be a detailed exception in it. My guess is that it might have something to do with the deployment descriptors.
    If you could post the deployment descriptors and the exception stack trace, it would be easier to figure out.

  • Error while loading java program using loadjava

    Hi
    I have oracle 8.1.7 in NT server. When I try to load a java program with load java it gives me the error like this
    Error while resolving class EchoInput
    ORA-00904: invalid column name
    loadjava: 1 errors
    Why this is happening. How can I resolve this. Any help is appreciated
    Thanks
    Santhosh

    You need to install teh jserver component.
    have your dba review this and run all java enabling scripts.
    look for it in the doc as initjvm.sql.

  • Error while deploying .sda file using t-code Sdoe_upload_archive

    Dear all,
             After transport all the SWDC to another client, i try to deploy the sca file using the tcode Sdoe_upload_archive and i am getting this error : " DataObject Transid '005056C000081DDD9BA073B0B4974E15' doesnot exist/is inactive in DOE.
           Can anyone pls share some idea how to resolve this problem? thank you
    Regards,
    Joan

    Hi,
    Were you able to reach the screen mobile component administration?
    From sap easy access menu>click the user menu>Data Orchestration Admin and Mon portal-->administration link
    You mean you are not able to find the MCD at all?I guess your mobile component will be of type application.
    May be you can scan through the MCDs listed after a wild card search and check the dataobject dependencies for each.
    Some how the MCD that you are trying to upload contains dataobjects that are not present in the system.
    You mentioned 'After transport all the SWDC to another client' , what exactly was done in this step?
    Regards,
    Liji

  • Error while uploading tiff file using report "RSTXLDMC"

    Hi Experts,
    I am trying to upload .tif file into SAP usinf report "RSTXLDMC".
    Getting below error.
    Uploading TIFF Files to SAPscript Texts
    Load File
    c:\file.tif
    The file contains    134,412  bytes
    This is a TIFF file with MOTOROLA byte order
    First IFD offset:                                        8
    Reading IFD from offset          8  Number of Tags         13
    ImageWidth:                                          5,120
    ImageLength:                                         6,590
    Compression:                                             2
    Photometric Interpretation:                              0
    Number of StripOffsets:                                  5
    RowsPerStrip:                                        1,636
    Number of StripByteCounts:                               5
    XResolution:                                           600  /          1
    YResolution:                                           600  /          1
    ResolutionUnit:                                          2
    This is a baseline TIFF 6.0 BILEVEL file
    TIFF upload not possible, compression type 2 not supported
    How to solve this ????
    Please help.
    Regards,
    SVS

    Dear Vijay,
    I have one tiff 6.0 image which i am passing to program "RSTXLDMC".
    I have not done any conversion or changes in the file.
    Regards,
    Sagar Sontakke

  • Getting Error while decrypt a file using Blowfish algorithm

    I am using blowfish algorithm for encrypt and decrypt my file. this is my code for encrypting decrypting .
    while i am running program i am getting an Exception
    Exception in thread "main" javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA6275)
    at javax.crypto.Cipher.doFinal(DashoA12275)
    at Blowfishexe.main(Blowfishexe.java:65)
    import java.security.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.io.*;
    import org.bouncycastle.crypto.CryptoException;
    import org.bouncycastle.crypto.KeyGenerationParameters;
    import org.bouncycastle.crypto.engines.DESedeEngine;
    import org.bouncycastle.crypto.generators.DESedeKeyGenerator;
    import org.bouncycastle.crypto.modes.CBCBlockCipher;
    import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
    import org.bouncycastle.crypto.params.DESedeParameters;
    import org.bouncycastle.crypto.params.KeyParameter;
    import org.bouncycastle.util.encoders.Hex;
    public class Blowfishexe {
    public static void main(String[] args) throws Exception {
    KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");
              kgen.init(128);
              String keyfile="C:\\Encryption\\BlowfishKey.dat";
    SecretKey skey = kgen.generateKey();
    byte[] raw = skey.getEncoded();
    SecretKeySpec skeySpec = new SecretKeySpec(raw, "Blowfish");
              System.out.println("key"+raw);
                   byte[] keyBytes = skey.getEncoded();
                   byte[] keyhex = Hex.encode(keyBytes);
                   BufferedOutputStream keystream =
    new BufferedOutputStream(new FileOutputStream(keyfile));
                        keystream.write(keyhex, 0, keyhex.length);
    keystream.flush();
    keystream.close();
    Cipher cipher = Cipher.getInstance("Blowfish");
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
              System.out.println("secretKey"+skeySpec);
    FileOutputStream fos=new FileOutputStream("C:\\Encryption\\credit11.txt");
              BufferedReader br=new BufferedReader(new FileReader("C:\\Encryption\\credit.txt"));
              String text=null;
              byte[] plainText=null;
              byte[] cipherText=null;
              while((text=br.readLine())!=null)
              System.out.println(text);
              plainText = text.getBytes();
              cipherText = cipher.doFinal(plainText);
              fos.write(cipherText);
              br.close();
              fos.close();
              cipher.init(Cipher.DECRYPT_MODE, skeySpec);
              FileOutputStream fos1=new FileOutputStream("C:\\Encryption\\BlowfishOutput.txt");
              BufferedReader br1=new BufferedReader(new FileReader("C:\\Encryption\\credit11.txt"));
              String text1=null;
              /*while((text1=br1.readLine())!=null)
                   System.out.println("text is"+text1);
                   plainText=text1.getBytes("UTF8");
                   cipherText=cipher.doFinal(plainText);
                   fos1.write(cipherText);
              br1.close();
              fos1.close();
    //byte[] encrypted = cipher.doFinal("This is just an example".getBytes());
              //System.out.println("encrypted value"+encrypted);*/
    Any one pls tell me how to slove my problem
    thanks in advance

    hi
    i got the solution. its working now
    but blowfish key ranges from 56 to448
    while i am writing the code as
    KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
    keyGenerator.init(448);
    this code is generating the key upto 448 bits
    but coming to encoding or decode section key length is not accepting
    cipher.init(Cipher.ENCRYPT_MODE, key);
    Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.init(DashoA12275)
    at javax.crypto.Cipher.init(DashoA12275)
    at Blowfish1.main(Blowfish1.java:46)
    i am getting this error
    what is the solution for this type of exception.
    thank you

Maybe you are looking for

  • Can't Copy a File Name?

    I just upgraded to CS5 from CS2. I always used to be able to copy the file name of a new file in the save screen and then paste that filename to new folder when I saved it. I can't seem to do  that any longer..any one know why or how to change that?

  • How to delete/reset Photoshop preferences

    Background: Sometimes Photoshop can exhibit odd/erratic/weird behaviour. The first step is to make sure that you are running the latest version of Photoshop, by applying the relevant updates for your version of Photoshop listed on this page: http://w

  • Document Split on Non Leading Ledger

    Hi Friends, Can we activate document split on Non leading Ledgers also? Actually my client wants to maintain Leading ledger as per US GAAP and Non leading ledgers as per Schedule VI So there is a requirement of activating document split on the non le

  • Samsung SGH-L768 - Unsupported file type

    I have downloaded games for my Samsung SGH-L768 but everytime i try to open it "unsupported file type" appears. I have resized game resulotion but still nothing happened. I believed my mobile is java compatible ----- WHAT'S WRONG? NEED HELP....

  • Help - pet registration form

    Hi, i have two tables: pet_owner and pet...trying to make a pet registration form....owner might have more than one pet. ho do i create a form with the owner's details at the top, then a drop down, how many pet would you like to register? [1][2][3] a