Exception in thread "Thread-4" java.lang.IllegalAccessError

Hi All,
I am getting this error at run-time while trying to run below code
Exception in thread "Thread-4" java.lang.IllegalAccessError
CODE:
================================
* FileName : UMAC.java *
* Program Details : For getting Signed data. *
* Invoked From : SignedDataImpl.java *
package sfmsbr.bankapi;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Security;
import java.security.Signature;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.Enumeration;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import com.ibm.misc.BASE64Decoder;
import com.ibm.misc.BASE64Encoder;
import sun.security.pkcs.ContentInfo;
import sun.security.pkcs.PKCS7;
import sun.security.pkcs.PKCS9Attribute;
import sun.security.pkcs.PKCS9Attributes;
import sun.security.pkcs.SignerInfo;
import com.ibm.security.util.DerOutputStream;
/*import sun.security.x509.AlgorithmId;*/
import com.ibm.security.x509.AlgorithmId;
/*import sun.security.x509.X500Name;*/
import com.ibm.security.x509.X500Name;
/*import com.ibm.jsse.IBMJSSEProvider;*/
import org.apache.harmony.security.asn1.DerInputStream;
import com.cs.common.Utilities;
import com.sun.net.ssl.internal.ssl.Provider;
/*import javax.net.ssl.*;*/
import sun.security.pkcs.*;
public class UMAC
private static String storetype = null;
private static String storepath = null;
private static char keyPassword[] = null;
private static char filePassword[] = null;
private static String alias = null;
private static X509Certificate x509 = null;
private static Certificate certs[] = null;
private static final String digestAlgorithm = "SHA256";
private static final String signingAlgorithm = "SHA256withRSA";
private static Key key = null;
private static KeyPair pair = null;
private static KeyStore keystore = null;
private static PrivateKey priv = null;
private static PublicKey pub = null;
private static String signedData = null;
File certificateFile;
private static String fileName = "";
private static final String ALGORITHM = "PBEWithSHA256AndDes";
private String characterEncoding;
private Cipher encryptCipher;
private Cipher decryptCipher;
private BASE64Encoder base64Encoder = new BASE64Encoder();
private BASE64Decoder base64Decoder = new BASE64Decoder();
* Constructor to initialize the Parameters used
* @param s file name/path
* @param s1 is file password
* @param s2 is key password
* @param s3 is alias name
* @throws IOException
public UMAC(String s, String s1, String s2, String s3) throws IOException
try {
String dkeyPassword = Utilities.decodeDBPwd(s2);
String dFilePassword = Utilities.decodeDBPwd(s1);
keyPassword = (new String(dkeyPassword)).toCharArray();
filePassword = (new String(dFilePassword)).toCharArray();
alias = s3;
fileName = s;
} catch (Exception e) {
e.printStackTrace();
* method will prepare the digital signature for the message received as argument and returns the digital signature
* @param s the message to prepare signed data
* @return signed data prepard for the message received
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws IllegalBlockSizeException
* @throws NoSuchProviderException
* @throws BadPaddingException
* @throws NoSuchPaddingException
* @throws Exception
public String getSingedData(String s) throws NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, NoSuchProviderException, BadPaddingException, NoSuchPaddingException, Exception
Security.addProvider(new Provider()); // addProvider(Provider provider).. Adds a provider to the next position available.
System.out.println("reached here a");
certificateFile = new File(fileName);
/*keystore = KeyStore.getInstance("pkcs12", "SunJSSE");*/
keystore = KeyStore.getInstance("pkcs12", "IBMJCE");
System.out.println("reached here b");
BASE64Encoder base64encoder = new BASE64Encoder();
System.out.println("reached here ba");
keystore.load(new FileInputStream(certificateFile), filePassword);
System.out.println("reached here bb");
Enumeration enumeration = keystore.aliases();
do {
if(!enumeration.hasMoreElements())
break;
String s1 = enumeration.nextElement().toString();
if(keystore.isKeyEntry(s1))
alias = s1;
} while(true);
System.out.println("reached here c");
pair = getPrivateKey(keystore, alias, keyPassword);
priv = pair.getPrivate();
String s2 = base64encoder.encode(priv.getEncoded());
if(keystore.isKeyEntry(alias))
certs = keystore.getCertificateChain(alias);
if(certs[0] instanceof X509Certificate)
x509 = (X509Certificate)certs[0];
if(certs[certs.length - 1] instanceof X509Certificate)
x509 = (X509Certificate)certs[certs.length - 1];
} else
if(keystore.isCertificateEntry(alias))
Certificate certificate = keystore.getCertificate(alias);
if(certificate instanceof X509Certificate)
x509 = (X509Certificate)certificate;
certs = (new Certificate[] {
x509
} else {
throw new Exception(alias + " Wrong alias, Please Check");
AlgorithmId aalgorithmid[] = {
AlgorithmId.get("SHA256")
byte abyte0[] = s.getBytes("UTF8");
System.out.println("reached here d");
MessageDigest messagedigest = MessageDigest.getInstance("SHA256");
messagedigest.update(abyte0);
byte abyte1[] = messagedigest.digest();
PKCS9Attribute apkcs9attribute[] = {
new PKCS9Attribute(PKCS9Attribute.CONTENT_TYPE_OID, ContentInfo.DATA_OID), new PKCS9Attribute(PKCS9Attribute.SIGNING_TIME_OID, new Date()), new PKCS9Attribute(PKCS9Attribute.MESSAGE_DIGEST_OID, abyte1)
PKCS9Attributes pkcs9attributes = new PKCS9Attributes(apkcs9attribute);
Signature signature = Signature.getInstance("SHA256withRSA", "SunJSSE");
signature.initSign(priv);
signature.update(pkcs9attributes.getDerEncoding());
byte abyte2[] = signature.sign();
ContentInfo contentinfo = null;
contentinfo = new ContentInfo(ContentInfo.DATA_OID, null);
X509Certificate ax509certificate[] = {
x509
java.math.BigInteger biginteger = x509.getSerialNumber();
SignerInfo signerinfo = new SignerInfo(new X500Name(x509.getIssuerDN().getName()), biginteger, AlgorithmId.get("SHA256"), pkcs9attributes, new AlgorithmId(AlgorithmId.RSAEncryption_oid), abyte2, null);
SignerInfo asignerinfo[] = {
signerinfo
PKCS7 pkcs7 = new PKCS7(aalgorithmid, contentinfo, ax509certificate, asignerinfo);
DerOutputStream deroutputstream = new DerOutputStream();
pkcs7.encodeSignedData(deroutputstream);
byte abyte3[] = deroutputstream.toByteArray();
String s3 = new String(abyte3);
BASE64Encoder base64encoder1 = new BASE64Encoder();
String s4 = base64encoder1.encodeBuffer(abyte3);
BASE64Decoder base64decoder = new BASE64Decoder();
System.out.println("reached here e");
byte abyte4[] = base64decoder.decodeBuffer(s4);
PKCS7 pkcs7_1 = new PKCS7(abyte4);
SignerInfo asignerinfo1[] = null;
if(pkcs7_1.getContentInfo().getContentBytes() == null)
byte abyte5[] = s.getBytes("UTF8");
asignerinfo1 = pkcs7_1.verify(abyte5);
} else
asignerinfo1 = pkcs7.verify();
if(asignerinfo1 == null) {
throw new Exception("Signature failed verification, data has been tampered");
} else {
Utilities.log(3, "asignerinfo1 is not null Verification OK>>" + new Date(System.currentTimeMillis()), "UMAC", "run");
return s4;
* gets the private key for opening the signing file
* @param keystore1
* @param s is file path
* @param ac
* @return keypair
* @throws Exception
public KeyPair getPrivateKey(KeyStore keystore1, String s, char ac[]) throws Exception
PublicKey publickey;
System.out.println("inside UMAC.getPrivateKey");
key = keystore1.getKey(s, ac);
System.out.println("key --->" +key);
if(!(key instanceof PrivateKey))
return null;
Certificate certificate = keystore1.getCertificate(s);
publickey = certificate.getPublicKey();
System.out.println("Returning from UMAC.getPrivateKey : publickey is --->" +publickey);
return new KeyPair(publickey, (PrivateKey)key);
===========================================
Its compiling properly but at run-time it's showing below error
OUTPUT:
===========================================
reached here a
reached here b
reached here ba
Exception in thread "Thread-4" java.lang.IllegalAccessError
at sun.security.util.DerInputStream.init(Unknown Source)
at sun.security.util.DerInputStream.<init>(Unknown Source)
at sun.security.rsa.RSAPublicKeyImpl.parseKeyBits(Unknown Source)
at sun.security.x509.X509Key.decode(X509Key.java:396)
at sun.security.x509.X509Key.decode(X509Key.java:408)
at sun.security.rsa.RSAPublicKeyImpl.<init>(Unknown Source)
at sun.security.rsa.RSAKeyFactory.generatePublic(Unknown Source)
at sun.security.rsa.RSAKeyFactory.engineGeneratePublic(Unknown Source)
at java.security.KeyFactory.generatePublic(KeyFactory.java:145)
at com.ibm.security.x509.X509Key.buildX509Key(X509Key.java:278)
at com.ibm.security.x509.X509Key.parse(X509Key.java:189)
at com.ibm.security.x509.X509Key.parse(X509Key.java:215)
at com.ibm.security.x509.CertificateX509Key.<init>(CertificateX509Key.java:112)
at com.ibm.security.x509.X509CertInfo.parse(X509CertInfo.java:966)
at com.ibm.security.x509.X509CertInfo.<init>(X509CertInfo.java:236)
at com.ibm.security.x509.X509CertInfo.<init>(X509CertInfo.java:222)
at com.ibm.security.x509.X509CertImpl.parse(X509CertImpl.java:2285)
at com.ibm.security.x509.X509CertImpl.<init>(X509CertImpl.java:227)
at com.ibm.security.x509.X509CertImpl.<init>(X509CertImpl.java:213)
at com.ibm.security.pkcs12.CertBag.decode(CertBag.java:599)
at com.ibm.security.pkcsutil.PKCSDerObject.decode(PKCSDerObject.java:251)
at com.ibm.security.pkcs12.CertBag.<init>(CertBag.java:76)
at com.ibm.security.pkcs12.BasicPFX.getCertificates(BasicPFX.java:1422)
at com.ibm.security.pkcs12.PFX.getCertificates(PFX.java:549)
at com.ibm.crypto.provider.PKCS12KeyStore.engineLoad(Unknown Source)
at java.security.KeyStore.load(KeyStore.java:414)
at sfmsbr.bankapi.UMAC.getSingedData(UMAC.java:137)
at sfmsbr.bankapi.SignedDataImpl.getSingedData(SignedDataImpl.java:42)
at com.cs.sfms.SFMSMessageSender.run(SFMSMessageSender.java:226)
at java.lang.Thread.run(Thread.java:736)
18:10:05 10-Feb-2012 AFTER JAVA Execution
Please share your valuable inputs to resolve this
Regards,
Haris

java version
java version "1.6.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pap32devifx-20110211b (SR12 FP3 +IZ94331))
IBM J9 VM (build 2.3, J2RE 1.6.0 IBM J9 2.3 AIX ppc-32 j9vmap3223ifx-20101130 (JIT enabled)
J9VM - 20101129_69669_bHdSMr
JIT - 20100623_16197ifx1_r8
GC - 20100211_AA)
JCL - 20110208
Regards
Haris
Edited by: user12848704 on Feb 10, 2012 3:27 AM

Similar Messages

  • Exception in thread "main" java.lang.NoClassDefFoundError

    Am using java 1.3.1 on Red Hat Linux 7.1
    i get this error
    Exception in thread "main" java.lang.NoClassDefFoundError
    while running a simple program HelloWorld.java
    help

    When you use the "java" command, the only required argument is the name of the class that you want to execute. This argument must be a class name, not a file name, and class names are case sensitive. For example, "java HelloWorld.java" won't work because the class name isn't HelloWorld.java, it's HelloWorld. Similarly, "java helloworld" won't work because a class defined as "public class HelloWorld {" is not named helloworld due to case sensitivity. Finally, the .class file must be in a directory that is in the Classpath - that's where java.exe searches to find the file that contains the class.

  • HELP Needed with this error:   Exception in thread "main" java.lang.NoClass

    Folks,
    I am having a problem connecting to my MSDE SQL 2000 DB on a WindowsXP pro. environment. I am learning Java and writing a small test prgm to connect the the database. The code compiles ok, but when I try to execute it i keep getting this error:
    "Exception in thread "main" java.lang.NoClassDefFoundError: Test1"
    I am using the Microsoft jdbc driver and my CLASSPATH is setup correctly, I've also noticed that several people have complained about this error, but have not seen any solutions....can someone help ?
    Here is the one of the test programs that I am using:
    import java.sql.*;
    * Microsoft SQL Server JDBC test program
    public class Test1 {
    public Test1() throws Exception {
    // Get connection
    DriverManager.registerDriver(new
    com.microsoft.jdbc.sqlserver.SQLServerDriver());
    Connection connection = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://LAPTOP01:1433","sa","sqladmin");
    if (connection != null) {
    System.out.println();
    System.out.println("Successfully connected");
    System.out.println();
    // Meta data
    DatabaseMetaData meta = connection.getMetaData();
    System.out.println("\nDriver Information");
    System.out.println("Driver Name: "
    + meta.getDriverName());
    System.out.println("Driver Version: "
    + meta.getDriverVersion());
    System.out.println("\nDatabase Information ");
    System.out.println("Database Name: "
    + meta.getDatabaseProductName());
    System.out.println("Database Version: "+
    meta.getDatabaseProductVersion());
    } // Test
    public static void main (String args[]) throws Exception {
    Test1 test = new Test1();

    I want to say that there was nothing wrong
    with my classpath config., I am still not sure why
    that didn't work, there is what I did to resolved
    this issue.You can say that all you like but if you are getting NoClassDefFound errors, that's because the class associated with the error is not in your classpath.
    (For future reference: you will find it easier to solve problems if you assume that the problem is your fault, instead of trying to blame something else. It almost always is your fault -- at least that's been my experience.)
    1. I had to set my DB connection protocol to TCP/IP
    (this was not the default), this was done by running
    the
    file "svrnetcn.exe" and then in the SQL Server Network
    Utility window, enable TCP/IP and set the port to
    1433.Irrelevant to the classpath problem.
    2. I then copied all three of the Microsoft JDBC
    driver files to the ..\jre\lib\ext dir of my jdk
    installed dir.The classpath always includes all jar files in this directory. That's why doing that fixed your problem. My bet is that you didn't have the jar file containing the driver in your classpath before, you just had the directory containing that jar file.
    3. Updated my OS path to located these files
    and....BINGO! (that simple)Unnecessary for solving classpath problems.
    4. Took a crash course on JDBC & basic Java and now I
    have created my database, all tables, scripts,
    stored procedures and can read/write and do all kinds
    of neat stuff.All's well that ends well. After a few months you'll wonder what all the fuss was about.

  • Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.dr

    Hi
    I am trying to use type 4 driver to connect to my Oracle 9i Rel2 database. I downloaded the odbc14.jar from oracle and added in the C:\Oracle9i\jdbc\lib path. As on the website, I setup my environment:
    Setting Up Your Environment
    On Win95/Win98/NT:
    - Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
    [ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x or 1.3 is
    used. Add ojdbc14.jar and nls_charset12.zip if JDK 1.4 is used.)
    - Make sure [ORACLE_HOME]\bin is in your PATH.
    Still I am getting the following error during runtime:
    Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at jdbc.InsertQueryEx.main(InsertQueryEx.java:11)
    Below is the source code:
    import java.sql.*;
    import java.io.*;
    public class InsertQueryEx {
    public static void main(String[] args)throws Exception{
    Class.forName("oracle.jdbc.OracleDriver");
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@Prashy:1521:orcl", "scott", "tiger");
    DataInputStream din = new DataInputStream(System.in);
    Statement stmt = con.createStatement();
    while(true){
    try{
    System.out.println("enter emp name");
    String name = din.readLine();
    System.out.println("enter emp no");
    int no = Integer.parseInt(din.readLine());
    System.out.println("enter emp salary");
    float sal = Float.parseFloat(din.readLine());
    System.out.println("enter emp address");
    String addr = din.readLine();
    int count = stmt.executeUpdate("insert into myemp values("+no+",'"+name+"',"+sal+",'"+addr+"')");
    if(count>0)
    System.out.println("Record added");
    else
    System.out.println("Failed");
    catch (Exception e){
    System.err.println("Exception: "+e.getMessage());
    Any help is appreciated
    Thanks
    Prashant

    I am sorry but I did add those in the classpath but still getting this error:
    This is what I have for user variable in classpath:
    .;C:\Oracle9i\jdbc\lib\ojdbc14.jar;C:\Oracle9i\jdbc\lib\nls_charset12.jar
    error is:
    java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at jdbc.InsertQueryEx.main(InsertQueryEx.java:14)
    Thanks

  • Exception in thread "main" java.lang.VerifyError: verification failed!!

    DB:11.1.0.7
    Oracle Apps:12.1.1
    OS:RHEL Linux 4 86x64
    Hi All,
    On executing the following command on node 2 of TEST instance, we received the following error but did not find any such error messages in node 1
    Notes: (1) Node 1 has java version:
    java -version
    java version "1.6.0_10"
    Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
    Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)
    (2) Node 2 has java version:
    java -version
    java version "1.4.2"
    gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9)
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Error message in node2:
    On executing the following command on node 2 of TEST instance, we received the following error:
    java oracle.jrad.tools.xml.importer.XMLImporter /tmp/custdocs/oracle/apps/pos/home/webui/customizations/site/0/PosHpgOrders.xml ....
    /usr/bin/java: line 36: [: `)' expected, found -
    Exception in thread "main" java.lang.VerifyError: verification failed at PC 152 in oracle.jdbc.driver.OracleDriver:registerMBeans(()V): String, int, or float constant expected
    at JvBytecodeVerifier.verify_fail(byte, int) (/usr/lib64/libgcj.so.5.0.0)
    at JvBytecodeVerifier.verify_instructions_0() (/usr/lib64/libgcj.so.5.0.0)
    at JvVerifyMethod(_Jv_InterpMethod) (/usr/lib64/libgcj.so.5.0.0)
    at JvPrepareClass(java.lang.Class) (/usr/lib64/libgcj.so.5.0.0)
    at JvWaitForState(java.lang.Class, int) (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.Class.initializeClass() (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib64/libgcj.so.5.0.0)
    at oracle.adf.mds.tools.util.ConnectUtils.getDBConnection(java.lang.String) (Unknown Source)
    at oracle.jrad.tools.xml.importer.XMLImporter.importDocuments(java.lang.String[], java.sql.Connection) (Unknown Source)
    at oracle.jrad.tools.xml.importer.XMLImporter.main(java.lang.String[]) (Unknown Source)
    Could anyone please share such an issue faced before and provide resolution as to what's wrong in here in node 2?
    Thanks for your time!
    Regards,

    Hi,
    (2) Node 2 has java version:
    java -version
    java version "1.4.2"Do you run this command as applmgr user? If yes, did you source the application env file?
    Could anyone please share such an issue faced before and provide resolution as to what's wrong in here in node 2?Why the java version is different on the both nodes?
    Thanks,
    Hussein

  • Exception in thread "main" java.lang.NullPointerException

    hi
    I am new to Java, and taking an introductory course in java. I wrote the code given bellow and get following error "C:\java\assingment2>java test123
    Exception in thread "main" java.lang.NullPointerException
    at PartCatalog.Add(test123.java:56)
    at test123.main(test123.java:102)"
    Can any body help me please
    import java.util.*;
    class PartRecord
    public String PartName;
    public String PartNumber;
    public float Cost;
    public int Quantity;
    public static int counter ;
    public PartRecord()
    { PartName ="";
         PartNumber="";
    Cost = 0;
         Quantity = 0;
         counter = 0;
    public void Set(String name, final String num,
    float cost, int quantity)
         PartName = name;
    PartNumber= num;
    Cost = cost;
    Quantity = quantity;
    counter++;
    public float Get()
                   return Cost*Quantity;
    public static int Counter() {return counter;}
    class PartCatalog
    public PartCatalog()
    npart=0;
    public void Add(String name, String num,
    float cost, int quantity)
    if(npart>=1000) return;
    Parts[npart++].Set(name,num,cost,quantity);
    public float ShowInventory()
    int inventory = 0;
    for(int i=0; i<npart; i++)
    inventory+= Parts.Get();
    return inventory;
    public PartRecord[] Parts = new PartRecord[1000];
    public int npart;
    class ExtPartCatalog extends PartCatalog
    public void Sort()
    Arrays.sort(Parts);
    public void Print()
    for(int i=0; i<npart; i++)
    System.out.println ( Parts[i].PartName + "\t "
    + Parts[i].PartNumber + "\t "
    + Parts[i].Cost + "\t "
    + Parts[i].Quantity + "\n");
    class test123{
    public static void main(String args[])          
         ExtPartCatalog catalog = new ExtPartCatalog();
         catalog.Add("tire ", "1", 45, 200);
         catalog.Add("microwave", "2", 95, 10);
         catalog.Add("CD Player", "3", 215, 11);
         catalog.Add("Chair ", "4", 65, 10);
         catalog.Sort();
    catalog.Print();
    System.out.println("Inventory is " + catalog.ShowInventory());
    ExtPartCatalog catalog2 = new ExtPartCatalog();
    catalog2.Add("ttt ", "1", 45, 200);
    System.out.print("\n\nTotally there are " + PartRecord.Counter() );
    System.out.println(" Parts being set" );

    Thank you for your reply. I think i used
    public PartRecord[] Parts = new PartRecord[1000];
    so i have created the reference. I tries what you told me but it still did not work. I am putting the code again, but now in the formatted form so that you can read it more easily. I will appreciate your help. Thanks
    <code>
    import java.util.*;
    class PartRecord
    {      public String PartName;
    public String PartNumber;
    public float Cost;
    public int Quantity;
    public static int counter ;
         public PartRecord()
              PartName ="";
              PartNumber="";
              Cost = 0;
              Quantity = 0;
              //counter = 0;
         public void Set(String name, final String num,
    float cost, int quantity)
         PartName = name;
         PartNumber= num;
         Cost = cost;
         Quantity = quantity;
         counter++;
         public float Get()
         return Cost*Quantity;
         public static int Counter() {return counter;}
    class PartCatalog
    {      public PartRecord[] Parts = new PartRecord[1000];
         public int npart;
    public PartCatalog()
    npart=0;
         public void Add(String name, String num,
         float cost, int quantity)
         if(npart>=1000) return;
         Parts[npart++].Set(name,num,cost,quantity);
         public float ShowInventory()
              float inventory = 0;
              for(int i=0; i<npart; i++)
              inventory= Parts[npart].Get();
              return inventory;
    /*class ExtPartCatalog extends PartCatalog
         public void Sort()
         Arrays.sort(Parts);
         public void Print()
                   for(int i=0; i<npart; i++)
                   System.out.println ( Parts.PartName + "\t "
                                  + Parts[i].PartNumber + "\t "
                                  + Parts[i].Cost + "\t "
                             + Parts[i].Quantity + "\n");
    class azimi_a{
    public static void main(String args[])
    PartCatalog c = new PartCatalog() ;//= new PartCatalog[4];
    c.Add("tire ", "1", 45, 200);
    c.Add("microwave", "2", 95, 10);
    c.Add("CD Player", "3", 215, 11);
    c.Add("Chair ", "4", 65, 10);
    <code>

  • Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

    hi to all.
    iam getting this error: could any one give me the solution.
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at DinosaursDataLoader.getData(DinosaursDataLoader.java:49)
    at DinosaursPack.load(DinosaursPack.java:22)
    at DinosaursPack.<init>(DinosaursPack.java:18)
    at myproject.main(myproject.java:17)
    import java.util.*;
    import java.io.*;
    import javax.swing.ImageIcon;
    public class Driver {
        public static void main (String[] args) {
              // create a Scanner and grab the data . . .
                 File f=new File("C:\\Users\\hariprasad koineni\\Desktop\\r.txt");// my text file containes 12 dinosuor card info
              Scanner scanner = null;
              try {
                    scanner = new Scanner(f);
              } catch (FileNotFoundException fnf) {
                    System.out.println(fnf.getMessage());
                    System.exit(0);
            // scan file line-by-line
              scanner.useDelimiter("------------------------------------------------------------------");
              int y=0;
              while (scanner.hasNext()) {
                String line = scanner.next().trim();
                System.out.println(line);
                String bits[]= new String[19];
                String[] bit = line.split("\n");       // Regex available since Java 5
                for(int j=0;j<=(bit.length-1);j++){
                        String[] bis = bit[j].split(":");
                        System.out.println(bis[0]);
                        String t=bis[1].trim();
                        bits[j]=t;
                        System.out.println(bits[j]);
                        System.out.println(j);
                String t = bits[0];                        // title
                String imgFileName = bits[1];          // image file name
                float  h = Float.parseFloat(bits[2]);    // height
                String  w = bits[3];    // weight
                String  l = bits[4];    // length
                int  kr = Integer.parseInt(bits[5]);    // killer rating
                String  i = bits[6];     // intelligence
                int  a = Integer.parseInt(bits[7]);     // age
                String df = bits[8];                      // dino file
                // create the image
               y++;
             System.out.println(line);
             System.out.println(y);
    }

    h_koineni wrote:
    sorry
    iam getting the error:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at Driver.main(Driver.java:38)So meaning this line cause the exception:
    String t=bis[1].trim(); // hard-coded int literal 1That happens because, in line 36,
    String[] bis = bit[j].split(":");What will happen if the delimiter ':' is not found? It will return an array with a size of 1, and at this time referencing index 1 is out of bound, remember that the upper bound of an array is its size-1. One workaround is to put a selection structure after line 36.
    if (bis != null && bis.length == 2) {
        String t=bis[1].trim();
        bits[j]=t;
    }Then, recompile your code and try again.

  • Exception in thread "main" java.lang.NumberFormatException:For input String

    this is a code about arrylist. but when I debug it.it metion:Exception in thread "main" java.lang.NumberFormatException:For input String at java.lang.NumberFormatException.forInputString(numberFomatExceptionio java:48)
    at java.lang.Integer.parseInt(integer.java:468)
    at java.lang.Integer.parseInt(integer.java:497)
    at Get.getInt(manerger.java:208)
    at LinkList.insertFirst(manager.java:94)
    at manager.main(manager.java;20)
    this is my code:
    import java.io.*;
    import java.lang.*;
    public class manager
         public static void main(String args[]) throws IOException
         LinkList list=new LinkList();
         System.out.println("input S can scan the grade\ninput D can delete one entry\ninput U can update the entry\ninput A can add one entry\ninput E can end");
         int cr=System.in.read();
    switch(cr)
         case 'A':
         list.insertFirst();break;//this is 20 row
         case 'S':
         System.out.println("input the s");break;
         case 'D':
         System.out.println("input the d");break;
         case 'U':
         System.out.println("input the u");break;
    class Link
    public int number;
    public String name=new String();
    public int chs;
    public int eng;
    public int math;
    public Link next;
    public Link(int number,String name, int chs,int eng,int math)
    this.number=number;
    this.name=name;
    this.chs=chs;
    this.eng=eng;
    this.math=math;
    public Link()
         this(0,"",0,0,0);
    public void displayLink()
    System.out.println(number + " "+name+ " "+chs+ " "+eng+ " "+math+ " ");
    class LinkList
    public Link first;
    public LinkList()
    first = null;
    public boolean isEmpty()
    return first==null;
    public void displayList()
         System.out.println("");
         Link current=first;
         while(current!=null)
              current.displayLink();
              current=current.next;
         System.out.println("");
    public Link insertFirst() throws IOException
         Get getdata=new Get();
         int number=getdata.getInt();//this is 94 row
         String name=getdata.getString();
         int chs=getdata.getInt();
         int eng=getdata.getInt();
         int math=getdata.getInt();
         Link newLink = new Link(number,name,chs,eng,math);
         first=newLink;
         return first;
    public Link find(int key)
         Link current=first;
         while(current.number!=key)
              if(current.next==null)
              return null;
              else
              current=current.next;
         return current;
    public Link update(int key) throws IOException
         Link current=first;
         while(current.number!=key)
         if(current.next==null)
         return null;
         else
              System.out.println("Input the first letter of the subject:");
         int c=System.in.read();
         Get get=new Get();
              switch(c)
                   case 'c':
                   current.chs=get.getInt();break;
                   case 'e':
                   current.eng=get.getInt();break;
                   case 'm':
                   current.math=get.getInt();break;
         return current;
    public float average(char key)
         Link current=first;
         float total=0;
         float average=0;
         float counter=0;
         if(current==null)
         return 0;
         while(current!=null)
              switch(key)
                   case 'c':
                   total=current.chs+current.next.chs;break;
                   case 'e':
                   total=current.eng+current.next.eng;break;
                   case 'm':
                   total=current.math+current.next.math;break;
              current=current.next.next;
              counter++;
         average=total/counter;
         return average;
    public Link delete(int key)
         Link current=first;
         Link previous=first;
         while(current.number!=key)
              if(current.next==null)
              return null;
              else
                   previous=current;
                   current=current.next;
              if(current==first)
              first=first.next;
              else
              previous.next=current.next;
              return current;
    class Get
    public static String getString() throws IOException
    System.out.println("Input your name:");
    InputStreamReader str = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(str);
    String s = br.readLine();
    return s;
    public static int getInt() throws IOException
    System.out.println("Input your data:");
    String st = getString();
    return Integer.parseInt(st);//this is 208 row
    }

    It may be that the code in getString() returns a
    String that ends with a newline. If that is the
    problem, you can use
    return (Integer.parseInt(st)).trim();1. getString will never return a String ending in newline. BufferedReader.readLine strips off the newline.
    2. Even if you had a newline, String.trim doesn't trim newlines.
    3. You would need to trim the String, not the int:
    return (Integer.parseInt(st.trim()));As JimDinosaur said, you are passing bad data (the value of "st").
    In getInt, add this before trying to parse "st":
    System.out.println("###"+st+"###");What does it print?

  • Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5

    I am getting error:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
    Pls tell me where I am wrong:
    import javax.swing.JOptionPane;
    import java.io.File;
    import java.io.*;
    import java.io.IOException;
    import java.util.*;
    class Test {
    String lname, fname, finalLetterGrade, LetterGrade, sub1,sub2,sub3,sub4,sub5,sub;
    int testone = 0;
         int a=0,b,c,d,e, count= 0, abs = 0,j;
    int testtwo = 0;
    int testthree = 0;
    int testfour = 0;
    int testfive = 0;
    int finalExamGrade = 0;
      int i=0;
    int participation = 0;
    int lowScore = 0;
    int abs1,abs2,abs3,abs4,abs5;
    String s="absent";
    Character ch;
    String []name;   
    int []Mark;
    double finalNumericGrade = 0;
    public Test() {
    public void inputGrades()
    int input, row, col;
         Scanner scan = new Scanner(System.in);
         System.out.println("Enter the length of the square matrix: ");
         col = scan.nextInt(); 
    name = new String[col];
            Mark = new int[col];
            for(i = 0; i < col ; i++)
              name=JOptionPane.showInputDialog("Enter Student Name"+(i+1)+" Name: ");
    System.out.println(name[i]);
    for(j=0; j < col;j++)
    Mark[j]=Integer.parseInt(JOptionPane.showInputDialog("Marks "+(j+1)+" Mark: "));
    System.out.println(Mark[j]);
              System.out.println("Average-->"+getAverage());
              System.out.println("Student'-->"+toString());
    public double getAverage()
         if( Mark[0]==0 || Mark[1]==0 || Mark[2]==0 || Mark[3]==0 || Mark[4]==0)
    finalNumericGrade=((((float)(Mark[0])) + ((float)(Mark[1])) + ((float)(Mark[2])) + ((float)(Mark[3])) + ((float)(Mark[4])))/4);
    else
    finalNumericGrade=((((float)(Mark[0])) + ((float)(Mark[1])) + ((float)(Mark[2])) + ((float)(Mark[3])) + ((float)(Mark[4])))/5);;
    return finalNumericGrade;
    private String letterGrade(){
         //System.out.println(" +++ finalNumericGrade " + finalNumericGrade );
    if ((finalNumericGrade >= 3.50) & (finalNumericGrade <= 4))
    finalLetterGrade = "A";
    else
    if ((finalNumericGrade >= 2.50) & (finalNumericGrade < 3.50))
    finalLetterGrade = "B";
    else
    if ((finalNumericGrade >= 2) & (finalNumericGrade < 2.50))
    finalLetterGrade = "C";
    else
    if ((finalNumericGrade >= 1) & (finalNumericGrade < 2))
    finalLetterGrade = "D";
    else
    if (finalNumericGrade == 0)
    finalLetterGrade = "X";
    else finalLetterGrade ="Z";
    return finalLetterGrade;
    public int getAbsentee()
         if(testone == 0)
              abs1=1;
         if(testtwo == 0)
              abs2=1;
         if(testthree == 0)
              abs3=1;
         if(testfour == 0)
              abs4=1;
         if(testfive == 0)
              abs5=1;
         return abs=abs1+abs2+abs3+abs4+abs5;
    public String AbsentSub()
         if((testone < testtwo) & (testone < testthree) & (testone < testfour) & (testone < testfive))          
              sub=sub1;
         if((testtwo < testone) & (testtwo < testthree) & (testtwo < testfour) & (testtwo < testfive))
              sub=sub2;
         if((testthree < testone) & (testthree < testtwo) & (testthree < testfour) & (testthree < testfive))
              sub=sub3;
         if((testfour < testone) & (testfour < testthree) & (testfour < testtwo) & (testfour < testfive))
              sub=sub4;
         if((testfive < testone) & (testfive < testtwo) & (testfive < testthree) & (testfive < testfour))
              sub=sub5;
         return sub;
    public int getLowScore(){
    //Determine and return the lowest score
    lowScore = testone;
    if (testtwo < lowScore) lowScore = testtwo;
    if (testthree < lowScore) lowScore = testthree;
         if (testfour < lowScore) lowScore = testfour;
         if (testfive < lowScore) lowScore = testfive;
    return lowScore;
    public String toString() {
    String studentStringValue="\n\nStudent " sub1 " "+sub2+" "+sub3+" "+sub4+" "+sub5+ " Lowest Final Marks \n\n";
    studentStringValue+= name[i]+"\t";
    if(Mark[0]==0)
         studentStringValue+="" s "\t";
    else
         a=Mark[0];
         ch = new Character(((char) ((69-a))));
    studentStringValue+= Mark[0]+" "+ch+ "\t";
    if(Mark[1]==0)
         studentStringValue+="" s "\t";
    else
         b=Mark[1];
    ch = new Character(((char) ((69-b))));
    studentStringValue+= Mark[1]+" "+ch+ "\t";
    if(Mark[2]==0)
         studentStringValue+="" s "\t";
    else
         c=Mark[2];
    ch = new Character(((char) ((69-c))));
    studentStringValue+=Mark[2] +" "+ch+ "\t";
    if(Mark[3]==0)
         studentStringValue+="" s "\t";
    else
         d=Mark[3];
    ch = new Character(((char) ((69-d))));
    studentStringValue+= Mark[3] +" "+ch+ "\t";
    if(Mark[4]==0)
              studentStringValue+="" s "\t";
    else
         e=Mark[4];
    ch = new Character(((char) ((69-e))));
    studentStringValue+=Mark[4] +" "+ch+ "\t";
    try {
    BufferedWriter out = new BufferedWriter(new FileWriter(".//Marks3.txt", true));
    out.write(studentStringValue);
    out.close();
    } catch (IOException e) {
    //studentStringValue+=" " + abs + " ";
    //studentStringValue+=" " sub"\t";
    studentStringValue+=" " + finalNumericGrade + " \n\n";
    //studentStringValue+=" Final Letter Grade is: " + finalLetterGrade +"\n";
    return studentStringValue;
    }// toString
    public void printName(){
    System.out.print(" "+lname);
    System.out.print(" "+fname);
    public static void main(String[] args)
         Test s = new Test();
         s.inputGrades();
         System.out.println("Average-->" +s.getAverage());
         //System.out.println("Average-->" +s.setAverage());
         //System.out.println("Absent students in each Test-->" + s.getAbsentee());
         // s.getLowScore();
         //System.out.println("Final Letter Grade --> " + s.letterGrade());
         // s.AbsentSub();
         System.out.println(""+ s.toString());

    hi,
    I am getting error on line 232 n 339
    My error is :
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
    at Test.toString(Test.java:232)
    at Test.main(Test.java:339)
    my code is :
    import javax.swing.JOptionPane;
    import java.io.File;
    import java.io.*;
    import java.io.IOException;
    import java.util.*;
    class Test {
    String lname, fname, finalLetterGrade, LetterGrade, sub1,sub2,sub3,sub4,sub5,sub;
    int testone = 0;
         int a=0,b,c,d,e, count= 0, abs = 0,j,ab,abm=0,abj=0,abn=0,abd=0;
    int testtwo = 0;
    int testthree = 0;
    int testfour = 0;
    int testfive = 0;
    int finalExamGrade = 0;
      int i=0;
    int participation = 0;
    int lowScore = 0;
    int abs1,abs2,abs3,abs4,abs5;
    String s="absent";
    Character ch;
    String []name;
    String[] subj;
    int []Mark;
    double finalNumericGrade = 0;
    public Test() {
    public void inputGrades()
    int input, row, col;
         Scanner scan = new Scanner(System.in);
         System.out.println("Enter the length of Array: ");
         col = scan.nextInt(); 
    name = new String[col];
    subj = new String[5];
            Mark = new int[5];
            for(i = 0; i < col ; i++)
              name=JOptionPane.showInputDialog("Enter Student Name"+(i+1)+" Name: ");
    System.out.println(name[i]);
    for(j=0; j < 5;j++)
                        subj[j]=JOptionPane.showInputDialog("Enter Subject"+(j+1)+" Name: ");
    Mark[j]=Integer.parseInt(JOptionPane.showInputDialog("Marks "+(j+1)+" Mark: "));
                        System.out.println(subj[j]);
    System.out.println(Mark[j]);
                        System.out.println("Student'-->"+toString());
              System.out.println("Average Stu-->"+getAverage());
              getLowScore();
    public double getAverage()
         if( Mark[0]==0 || Mark[1]==0 || Mark[2]==0 || Mark[3]==0 || Mark[4]==0)
    finalNumericGrade=((((float)(Mark[0])) + ((float)(Mark[1])) + ((float)(Mark[2])) + ((float)(Mark[3])) + ((float)(Mark[4])))/4);
    else
    finalNumericGrade=((((float)(Mark[0])) + ((float)(Mark[1])) + ((float)(Mark[2])) + ((float)(Mark[3])) + ((float)(Mark[4])))/5);;
    return finalNumericGrade;
    private String letterGrade(){
         //System.out.println(" +++ finalNumericGrade " + finalNumericGrade );
    if ((finalNumericGrade >= 3.50) & (finalNumericGrade <= 4))
    finalLetterGrade = "A";
    else
    if ((finalNumericGrade >= 2.50) & (finalNumericGrade < 3.50))
    finalLetterGrade = "B";
    else
    if ((finalNumericGrade >= 2) & (finalNumericGrade < 2.50))
    finalLetterGrade = "C";
    else
    if ((finalNumericGrade >= 1) & (finalNumericGrade < 2))
    finalLetterGrade = "D";
    else
    if (finalNumericGrade == 0)
    finalLetterGrade = "X";
    else finalLetterGrade ="Z";
    return finalLetterGrade;
    /*****Java Absentee***/
    public int getAbsenteeJava()
         if((Mark[0]==0))     
              abj=abj+1;
         else
              abj=0;
              return abj;
    public void setAbsenteeJava()
              System.out.println("Absent in Java-->"+abj);
    /***Maths Absentee****/
         public int getAbsenteeMaths()
         if(Mark[1]==0)
              abm=abm+1;
         else
              abm=0;
              return abm;
         public void setAbsenteeMaths()
              System.out.println("Absent in Maths-->"+abm);
    /****Stats Absentee---*/
    public int getAbsenteeStat()
    sub3="Stats";
         if(Mark[2]==0)          
              abs=abs+1;
         else
              abs=0;
              return abs;
         public void setAbsenteeStat()
    System.out.println("Absent in Stats-->"+abs);
    /*****NEt Absentee****/
         public int getAbsenteeNet()
    sub4="Network";
         if(Mark[3]==0)          
              abn=abn+1;
         else
              abn=0;
              return abn;
    public void setAbsenteeNet()
    System.out.println("Absent in Network-->"+abn);
    /*****Database Absentee****/
         public int getAbsenteeData()
    sub5="Database";
         if(Mark[4]==0)          
              abd=abd+1;
         else
              abd=0;
              return abd;
         public void setAbsenteeData()
    System.out.println("Absent in Database-->"+abd);
    public String getLowScore(){
    //Determine and return the lowest score
    if(((subj[0].equals(sub1)) || (Mark[0]==0)))     
              sub="Java";
         else if(((subj[1].equals(sub2)) || (Mark[1]==0)))
              sub="Maths";
         else if(((subj[2].equals(sub3)) & (Mark[2]==0)))
              sub="Stats";
         else if(((subj[3].equals(sub4)) || (Mark[3]==0)))
              sub="Network";
         else if(((subj[4].equals(sub5)) || (Mark[4]==0)))
              sub="Database";
         return sub;
    public String toString() {
    String studentStringValue="\n\nStudent " subj[0] " "+subj[1]+" "+subj[2]+" "+subj[3]+" "+subj[4]+ " Lowest Final Marks \n\n";
         String nm = name[i];
    studentStringValue+= nm+"\t";
    if(Mark[0]==0)
         studentStringValue+="" s "\t";
    else
         {// 232: Line: getting ERROR here
         a=Mark[0];
         ch = new Character(((char) ((69-a))));
    studentStringValue+= Mark[0]+" "+ch+ "\t";
    if(Mark[1]==0)
         studentStringValue+="" s "\t";
    else
         b=Mark[1];
    ch = new Character(((char) ((69-b))));
    studentStringValue+= Mark[1]+" "+ch+ "\t";
    if(Mark[2]==0)
         studentStringValue+="" s "\t";
    else
         c=Mark[2];
    ch = new Character(((char) ((69-c))));
    studentStringValue+=Mark[2] +" "+ch+ "\t";
    if(Mark[3]==0)
         studentStringValue+="" s "\t";
    else
         d=Mark[3];
    ch = new Character(((char) ((69-d))));
    studentStringValue+= Mark[3] +" "+ch+ "\t";
    if(Mark[4]==0)
              studentStringValue+="" s "\t";
    else
         e=Mark[4];
    ch = new Character(((char) ((69-e))));
    studentStringValue+=Mark[4] +" "+ch+ "\t";
    //studentStringValue+=" " + abs + " ";
    studentStringValue+=" " sub"\t";
    studentStringValue+=" " + finalNumericGrade + " \n\n";
    //studentStringValue+=" Final Letter Grade is: " + finalLetterGrade +"\n";
    try {
    BufferedWriter out = new BufferedWriter(new FileWriter(".//Marks3.txt", true));
    out.write(studentStringValue);
    out.close();
    } catch (IOException e) {
    return studentStringValue;
    }// toString
    public void printName(){
    System.out.print(" "+lname);
    System.out.print(" "+fname);
    public static void main(String[] args)
         Test s = new Test();
         s.inputGrades();
         System.out.println("Average-->" +s.getAverage());
         //System.out.println("Average-->" +s.setAverage());
         s.getAbsenteeJava();
         s.setAbsenteeJava();
         s.getAbsenteeMaths();          
    s.setAbsenteeMaths();
         s.getAbsenteeStat();
         s.setAbsenteeStat();
         s.getAbsenteeNet();     
         s.setAbsenteeNet();
         s.getAbsenteeData();          
    s.setAbsenteeData();
         s.getLowScore();
         //System.out.println("Final Letter Grade --> " + s.letterGrade());
         System.out.println(""+ s.toString());

  • I get the message Exception in thread "main" java.lang.StackOverflowError

    I'm trying to make a program for my class and when I run the program I get the error Exception in thread "main" java.lang.StackOverflowError, I have looked up what it means and I don't see where in my program would be giving the error, can someone please help me, here is the program
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    // This visual application allows users to "shop" for items,
    // maintaining a "shopping cart" of items purchased so far.
    public class ShoppingApp extends JFrame
    implements ActionListener {
    private JButton addButton, // Add item to cart
    removeButton; // Remove item from cart
    private JTextArea itemsArea, // Where list of items for sale displayed
    cartArea; // Where shopping cart displayed
    private JTextField itemField, // Where name of item entered
    messageField; // Status messages displayed
    private ShoppingCart cart; // Reference to support object representing
    // Shopping cart (that is, the business logic)
    String itemEntered;
    public ShoppingApp() {
    // This array of items is used to set up the cart
    String[] items = new String[5];
    items[0] = "Computer";
    items[1] = "Monitor";
    items[2] = "Printer";
    items[3] = "Scanner";
    items[4] = "Camera";
    // Construct the shopping cart support object
    cart = new ShoppingCart(items);
    // Contruct visual components
    addButton = new JButton("ADD");
    removeButton = new JButton("REMOVE");
    itemsArea = new JTextArea(6, 8);
    cartArea = new JTextArea(6, 20);
    itemField = new JTextField(12);
    messageField = new JTextField(20);
    // Listen for events on buttons
    addButton.addActionListener(this);
    removeButton.addActionListener(this);
    // The list of items is not editable, and is in light grey (to
    // make it distinct from the cart area -- this would be done
    // better by using the BorderFactory class).
    itemsArea.setEditable(false);
    itemsArea.setBackground(Color.lightGray);
    cartArea.setEditable(false);
    // Write the list of items into the itemsArea
    itemsArea.setText("Items for sale:");
    for (int i = 0; i < items.length; i++)
    itemsArea.append("\n" + items);
    // Write the initial state of the cart into the cartArea
    cartArea.setText("No items in cart");
    // Construct layouts and add components
    JPanel mainPanel = new JPanel(new BorderLayout());
    getContentPane().add(mainPanel);
    JPanel controlPanel = new JPanel(new GridLayout(1, 4));
    controlPanel.add(new JLabel("Item: ", JLabel.RIGHT));
    controlPanel.add(itemField);
    controlPanel.add(addButton);
    controlPanel.add(removeButton);
    mainPanel.add(controlPanel, "North");
    mainPanel.add(itemsArea, "West");
    mainPanel.add(cartArea, "Center");
    mainPanel.add(messageField, "South");
    public void actionPerformed(ActionEvent e)
    itemEntered=itemField.getText();
    if (addButton==e.getSource())
    cart.addComputer();
         messageField.setText("Computer added to the shopping cart");
    public static void main(String[] args) {
    ShoppingApp s = new ShoppingApp();
    s.setSize(360, 180);
    s.show();
    this is a seperate file called ShoppingCart
    public class ShoppingCart extends ShoppingApp
    private String[] items;
    private int[] quantity;
    public ShoppingCart (String[] inputitems)
    super();
    items=inputitems;
    quantity=new int[items.length];
    public void addComputer()
    int x;
    for (x=0; "computer".equals(itemEntered); x++)
         items[x]="computer";
    please somebody help me, this thing is due tomorrow I need help asap!

    First, whenever you post, there is a link for Formatting Help. This link takes you to here: http://forum.java.sun.com/features.jsp#Formatting and tells you how to use the code and /code tags so any code you post will be easily readable.
    Your problem is this: ShoppingApp has a ShoppingCart and ShoppingCart is a ShoppingApp - that is ShoppingCart extends ShoppintApp. You are saying that ShoppingCart is a ShoppingApp - which probably doesn't make sense. But the problem is a child class always calls one of its parent's constructors. So when you create a ShoppingApp, the ShoppingApp constructor tries to create a ShoppingCart. The ShoppingCart calls its superclass constructor, which tries to create a ShoppingCart, which calls its superclass constructor, which tries to create a ShoppingCart, which...
    It seems like ShoppingCart should not extend ShoppingApp.

  • FB 4.7 AIR 3.6 Flex 4.9 iOS packing - Exception in thread "main" java.lang.OutOfMemoryError'

    I've got an error similar to Isaac_Sunkes' 'FB 4.7 iOS packaging - Exception in thread "main" java.lang.OutOfMemoryError',
    but the causes are not related to what he discovered, corrupt image or other files, I'd exclude bad archive contents in my project.
    I'm using Flash Builder 4.7 with Adobe AIR 3.6 set into an Apache Flex 4.9.1 SDK;
    HW system is:
    iMac,    2,7 GHz Intel Core i5,    8 GB 1600 MHz DDR3,    NVIDIA GeForce GT 640M 512 MB,    OS X 10.8.2 (12C3103)
    The Flash project consists in an application with a main SWF file which loads, via ActionScript methods, other SWF in cascade.
    I've formerly compiled and run the application on an iPad 1, IOS 5.0.1 (9A405), but got on the device the error alert:
    "Uncompiled ActionScript
    Your application is attempitng to run
    uncompiled ActionScript, probably
    due to the use of an embedded
    SWF. This is unsupported on iOS.
    See the Adobe Developer
    Connection website for more info."
    Then I changed the FB compiler switches, now are set to:
    -locale en_US
    -swf-version=19
    Please note that without the switch    -swf-version=19     the application is compiled correctly and the IPA is sent to the device
    and I can debug it, but iOS traps secondary SWF files and blocke the app usage, as previously told.
    they work on deploy of small applications,
    but, when I try to build a big IPA file either for an ad-hoc distribution, either for an debug on device, after some minutes long waiting, I get a Java stuck, with this trace:
    Error occurred while packaging the application:
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.util.HashMap.addEntry(HashMap.java:753)
        at java.util.HashMap.put(HashMap.java:385)
        at java.util.HashSet.add(HashSet.java:200)
        at adobe.abc.Algorithms.addUses(Algorithms.java:165)
        at adobe.abc.Algorithms.findUses(Algorithms.java:187)
        at adobe.abc.GlobalOptimizer.sccp(GlobalOptimizer.java:4731)
        at adobe.abc.GlobalOptimizer.optimize(GlobalOptimizer.java:3615)
        at adobe.abc.GlobalOptimizer.optimize(GlobalOptimizer.java:2309)
        at adobe.abc.LLVMEmitter.optimizeABCs(LLVMEmitter.java:532)
        at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:341)
        at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler .java:599)
        at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:104)
    I've tried to change the Java settings on FB's eclipse.ini in MacOS folder,
    -vmargs
    -Xms(various settings up to)1024m
    -Xmx(various settings up to)1024m
    -XX:MaxPermSize=(various settings up to)512m
    -XX:PermSize=(various settings up to)256m
    but results are the same.
    Now settings are back as recommended:
    -vmargs
    -Xms256m
    -Xmx512m
    -XX:MaxPermSize=256m
    -XX:PermSize=64m
    I've changed the Flex build.properties
    jvm.args = ${local.d32} -Xms64m -Xmx1024m -ea -Dapple.awt.UIElement=true
    with no results; now I'n get back to the standard:
    jvm.args = ${local.d32} -Xms64m -Xmx384m -ea -Dapple.awt.UIElement=true
    and now I truely have no more ideas;
    could anyone give an help?
    many thanks in advance.

    I solved this. It turns out the app icons were corrupt. After removing them and replacing them with new files this error went away.

  • On starting WebLogic getting Error : Listening for transport dt_socket at address: 8453 Exception in thread "main" java.lang.NoClassDefFoundError: vXmx512m

    Hi,
    system i am using for Oracle SOA is :
    Windows 64 Bit
    i5 Processor
    6 GB RAM
    29 GB on C Drive is already free after installation of all SOA related products.
    I have installed wlserver_10.3 for SOA 11g Development purpose and followed exact installation sequence and procedure as mention in oracle documentation
    i created domain also and every thing look correct but after installation procedure there are "Additional actions required just after every thing installed" :
    setting memory limit
    starting weblogic server (Admin Server)
    starting weblogic managed server
    and so on
    now Problem is when i execute C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin startWebLogic.cmd
    as mention in oracle documentation i am getting following error message : (i have only included last error lines instead of complete console log)
    oConsole= -Dweblogic.ext.dirs=C:\Oracle\MIDDLE~1\patch_wls1036\profiles\default\
    sysext_manifest_classpath;C:\Oracle\MIDDLE~1\patch_oepe180\profiles\default\syse
    xt_manifest_classpath;C:\Oracle\MIDDLE~1\patch_ocp371\profiles\default\sysext_ma
    nifest_classpath;C:\Oracle\MIDDLE~1\patch_adfr1111\profiles\default\sysext_manif
    est_classpath  weblogic.Server
    Listening for transport dt_socket at address: 8453
    Exception in thread "main" java.lang.NoClassDefFoundError: vXmx512m
    Caused by: java.lang.ClassNotFoundException: vXmx512m
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            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)
    Could not find the main class: ++Xmx512m.  Program will exit.
    Now to resolve this what i already tried are :
    I change JAVA_HOME and PATH to jdk6 which came with web logic installer
    Location is at :
    JAVA_HOME : C:\Oracle\Middleware\jdk160_29
    PATH : C:\Oracle\Middleware\jdk160_29\bin
    The above dose not include any space between path
    I ran the startWebLogic.cmd and got same error
    After that I also added
    CLASSPATH : C:\Oracle\Middleware\jdk160_29\lib\tool.jar;C:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\jdk160_29\bin
    WL_HOME:  C:\Oracle\Middleware\wlserver_10.3
    I ran the startWebLogic.cmd and got same error
    I also used earlier path which I used with eclipse when I was working on other java development.
    JAVA_HOME : C:\Program Files\Java\jdk1.7.0_21
    PATH : C:\Program Files\Java\jdk1.7.0_21\bin
    I ran the startWebLogic.cmd and got same error
    Then I also gave PATH: C:\Oracle\Middleware\wlserver_10.3\server\lib      (including the existing one using ; )
    I ran the startWebLogic.cmd and got same error
    Now may be there is a file called setSOADomainEnv.cmd in
    < C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin\ setSOADomainEnv.cmd>
    That include some values for memory set :
    set JAVA_OPTIONS=%JAVA_OPTIONS%
    set DEFAULT_MEM_ARGS=-Xms512m –Xmx512m
    set PORT_MEM_ARGS=-Xms512m –Xmx768m
    if "%JAVA_VENDOR%" == "Oracle" goto OracleJVM
    set DEFAULT_MEM_ARGS=%DEFAULT_MEM_ARGS% -XX:PermSize=128m -XX:MaxPermSize=768m
    set PORT_MEM_ARGS=%PORT_MEM_ARGS% -XX:PermSize=256m -XX:MaxPermSize=768m
    now as I change the red highlighted value to 512 value because I have less memory resource and I checked in installation documentation to change the above red highlighted value to 512 original is 1024 which is too high and it was crating problem and showing memory space problem so I change it to 512 and now I am not getting that memory space problem error but may be the above error is related with change value in setSOADomainEnv.cmd file or not
    Following are my domain, weblogic and soa home directory path and all these path are exactly what it suppose to be according to Oracle Installation Documentation:
    WebLogic :
    C:\Oracle\Middleware\wlserver_10.3
    C:\Oracle\Middleware\coherence_3.7
    C:\Oracle\Middleware\oepe_11.1.1.8.0
    SOA Oracle Home Directory :
    C:\Oracle\Middleware\Oracle_SOA1
    OSB Home Location :
    C:\Oracle\Middleware\Oracle_OSB1
    Domain name : soa_div_domain
    Domain Location :       C:\Oracle\Middleware\user_projects\domains
    Application Location :  C:\Oracle\Middleware\user_projects\applications
    Domain Location:        C:\Oracle\Middleware\user_projects\domains\soa_div_domain
    form here i am trying to start weblogic : C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin\startWebLogic.cmd
    Please tell me any body want more details.
    Thanks.

    I think you are missing a character '-'
    USER_MEM_ARGS="Xms512m -Xmx512m -XX:MaxPermSize=128m"Add this character like follows
    "-Xms512m -Xmx512m -XX:MaxPermSize=128m"

  • J2ee server Exception in thread Main java.lang.OutOfMemoryError

    hallo
    i need your help
    first my java j2ee and jdk
    j2ee j2sdkee1.3.1
    jdk j2sdk 1.4
    i nedd the server for jms.
    when i started the server with j2ee -verbose
    i get the error message:
    Starting web service at port: 8000
    Exception in thread "Main" java.lang.OutOfMemoryError
    what can i do to get out off this error message and starting the server normal. please help me to solve the problem!!!
    i read in this forum about -Xms und Xmx but this Commands don't go on my system.
    thx for help!!!

    Hi Warren,
    Still I am not clear with your question. But generally this out of memoryspace error can be rectified by changing the properties which comes in the menubar of your command prompt. Then increasing the virtual memory over there. I hope this will help you.
    Thanks
    Bakrudeen
    Technical Support Engineer
    Sun MicroSystems Inc, India

  • How to solve this problem"exception in thread "main" java.lang.noclassdeff"

    I am a tyro of java programming .
    i downloaded the j2sdk-1_4_2_09-windows-i586-p.exe from www.java.sun.com and installed it at the defaulted path C:\j2sdk1.4.2_09,
    then i wrote down my first java program as follow:
    public class hello
    public static void main (String args[])
    System.out.println("hello,����!");
    }and stored it at C:\Javasmp\ch01\hello.java.
    after that i opened dos commind window and compiled it :
    c:\javac C:\Javasmp\ch01\hello.java. and obtained file hello.class (C:\Javasmp\ch01\hello.class)
    but when running it (c:\java C:\Javasmp\ch01\hello) there was a mistake:
    exception in thread "main"java.lang.noclassdeffounderror:C:\Javasmp\ch01\hello
    i searched on the internet and found out the solution is set enviroment viriable ,so i set the "CLASSPATH" as".;C:\j2sdk1.4.2_09\lib;C:\j2sdk1.4.2_09\lib\tools.jar" ,"PATH" as"C:\j2sdk1.4.2_09\bin;C:\Windows\system32;c:\windows\system32\Wbem" and "JAVA_HOME" as "C:\j2sdk1.4.2_09\bin;C:\j2sdk1.4.2_09\jre\bin"
    afer that, i opened a new dos command window and run it again ,but the problem was still unsolved.
    in addition,my os is "windows xp"
    anyone can help me ,thank you!
    i am a student in China,it's a hard time for me to write down my question in english ,i doubt whether i express my question clearly.
    thank you for you reading.

    I have created a simple applet.
    import java.lang.*;
    import java.awt.*;
    public class jawtex3 extends java.applet.Applet
    public void init()
    add(new Button("One"));
    add(new Button("Two"));
    public Dimension preferredSize()
    return new Dimension(200, 100);
    public static void main(String [] args)
    Frame f = new Frame(" jawtex3");
    jawtex3 ex = new jawtex3();
    ex.init();
    f.add("Center", ex);
    f.pack();
    f.show();
    In this no compilation errors.
    I am getting runtime exception.as Exception in thread "main"java.lang.NoClassDefFound Error: jawtex
    reply me soon.
    thankyou.

  • How to resolve Exception in thread "main" java.lang.NoSuchFieldError: strm

    Hi,
    Aplogies, if I am posting this in the wrong place, else please guide me.
    We were running JBoss server 4.2.3 GA with Java 5 Update 19 in Solaris 10.
    Details of uname command in Solaris box is,
    uname -a
    SunOS uktapp06 5.10 Generic_125100-10 sun4us sparc FJSV,GPUZC-M
    Due to performance issues we need to upgrade to latest Java [Java 6 Update 21] and when I tried to run JBoss with 64 bit mode using Java options like,
    JAVA_OPTS="*-d64* -Xms3g -Xmx3g -XX:ThreadStackSize=512 -XX:+UseParallelGC -XX:MaxPermSize=256m -XX:NewRatio=2"
    I get the below error,
    Exception in thread "main" java.lang.NoSuchFieldError: strm
            at java.util.zip.Inflater.initIDs(Native Method)
            at java.util.zip.Inflater.<clinit>(Inflater.java:68)
            at java.util.zip.ZipFile.getInflater(ZipFile.java:266)
            at java.util.zip.ZipFile.getInputStream(ZipFile.java:212)
            at java.util.zip.ZipFile.getInputStream(ZipFile.java:180)
            at java.util.jar.JarFile.hasClassPathAttribute(JarFile.java:465)
            at java.util.jar.JavaUtilJarAccessImpl.jarFileHasClassPathAttribute(JavaUtilJarAccessImpl.java:21)
            at sun.misc.URLClassPath$JarLoader.getClassPath(URLClassPath.java:903)
            at sun.misc.URLClassPath.getLoader(URLClassPath.java:302)
            at sun.misc.URLClassPath.getResource(URLClassPath.java:168)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)I have posted this at JBoss Forum here, http://community.jboss.org/message/553489
    and got a response that we need to reinstall Java 6 Update 21 in Solaris
    However my System admin verified and said there are no issues in Java installation.
    I could run a HelloWorld sample program using the same Java options [with -d64 flag] and that runs perfectly.
    I do not have any clue because I do not think there is any issues in the JBoss server
    From the above trace, it is failing at a native call and not picking up the required libraries.
    Please also let me know the below
    1. Whether I need to set any environment variables?
    2. Whether the installation would have been corrupted and we need to reinstall?
    Thanks,
    Prabhu

    Hi Franco,
    Yes, I solved that by reinstalling Java 6 Update 21.
    There are three versions for Solaris namely, SPARC, x64 and x86. Our platform is SPARC and I think System admin has installed the wrong version instead of installing SPARC version of Java.
    After installing SPARC version of Java this got resolved. And I confirmed everything is fine by running a small program as below. You can run this program from command line using the -d64 flag. If the installation is wrong you will get the same exception as I mentioned.
    public class Analyzer {
          public static void main(String args[]) throws Exception{
               InputStream fin = new FileInputStream(args[0]);
               int iSize = fin.available();
               byte mvIn[] = new byte[iSize];
               fin.read(mvIn,0,iSize);
               fin.close();
               String strText = new String(mvIn);
               PrintStream fout = new PrintStream(new FileOutputStream(args[0]+".csv"));
               fout.println("Before,After,Seconds");
               Pattern p = Pattern.compile("\\[(?:Full |)GC (\\d*)K->(\\d*)K\\(\\d*K\\), ([\\d.]*) secs\\]");
               Matcher m = p.matcher(strText);
               while(m.find()){
                    fout.println(m.group(1)+ "," + m.group(2) + "," + m.group(3));
               fout.close();
    }Hope this helps.
    Regards,
    Prabhu

Maybe you are looking for

  • Video Card upgrade for HP Pavilion HPE h8-1256s Desktop

    I wanted to upgrade my current graphics card which was an NVIDIA GeForce GT 620, the mother board is a H-Joshua-H61-uATX. I recently bought an EVGA GeForce GTX 750Ti Superclock. I unistalled the old drivers took out the old card, added the new one an

  • 64-bit vs 32-bit installation

    Hi, I have developed .NET application on 32-bit system with Oracle 10g and works very well. When I have deployed the application on the Client server I am getting the following error "Attempt to load Oracle Cleint libraries threw BandImageFormatExcep

  • T420s external microphone won't work

      I just bought a T420s, Type 4174-P5G, I want to use an external stereo microphone (Sony ECM-719) instead of the built-in microphone, however as soon as I plug it in the headphone/microphone combined jack, the microphone is recognized as headphone.

  • OIM11g - disable set password on first logon + force challenge questions

    Hi all, I was initially trying to work out how to stop forcing users to set their passwords on first login. Initially by using the Force Password Change at First Login flag. I found the following in metalink: BUG:10256559: DOCUMENT THAT XL.FORCEPASSW

  • Setting up a plain network-account server

    To simplify a process I need to get done quickly, but have no knowledge of, I am asking for the support of the helpful users here in the discussions. The end product I need is a 10.5 server (already installed and not set up yet) to host network user