Exception in thread

Hello,
The problem is inside the method "chamaConversor".
" conversor.pdfToText(arquivoPdf,arquivoTxt);" make a file.txt from one file.pdf. After that it don?t return the control to "ConstrutorDeTemplate2.java", and show the following error message:
Exception in thread "AWT-EventQueue-O" java.lang.NoClassDefFoundError : org/fontbox/afm/FontMetric
at org.pdfbox.pdmodel.font.PDFont.getAFM (PDFont.java:334)
I am using the NetBeans IDE 5.5.
I have added all of these libraries below to my project from c:\Program Files\netbeans-5.5\PDFBox-0.7.3\external:
* FontBox-0.1.0-dev.jar
* ant.jar
* bcmail-jdk14-132.jar
* junit.jar
* bcprov-jdk14-132.jar
* lucene-core-2.0.0.jar
* checkstyle-all-4.2.jar
* lucene-demos-2.0.0.jar
and PDFBox-0.7.3.jar from c:\Program Files\netbeans-5.5\PDFBox-0.7.3\lib.
There are no more jar from PDFBox-0.7.3 directory.
All of these libraries are in "Compile-time Libraries" option in Project Properties. Should I add they to "Run-time Libraries" option?
What is going on?
Thank you!
  * ConstrutorDeTemplate2.java
  * Created on 11 de Agosto de 2007, 14:54
  * @author
package br.unifacs.dis2007.template2;
// Java core packages
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.*;
import java.util.*;
// Java extension packages
import javax.swing.*;
import org.pdfbox.*;
public class ConstrutorDeTemplate2 extends JFrame
    implements ActionListener {
    private JTextField enterField;
    private JTextArea outputArea;
    private BufferedWriter out;
    private String word;
    private PdfToText conversor = new PdfToText();
    // ajusta a interface do usu?rio
    public ConstrutorDeTemplate2()
       super( "Testing class File" );
       enterField = new JTextField("Digite aqui o nome do arquivo :" );
       enterField.addActionListener( this );
       outputArea = new JTextArea();
       ScrollPane scrollPane = new ScrollPane();
       scrollPane.add( outputArea );
       Container container = getContentPane();
       container.add( enterField, BorderLayout.NORTH );
       container.add( scrollPane, BorderLayout.CENTER );
       setSize( 400, 400 );
       show();
    // Exibe as informa??es sobre o arquivo especificado pelo usu?rio
    public void actionPerformed( ActionEvent actionEvent )
       File name = new File( actionEvent.getActionCommand() );
       // Se o arquivo existe, envia para a sa?da as informa??es sobre ele
       if ( name.exists() ) {
          outputArea.setText(
             name.getName() + " exists\n" +
             ( name.isFile () ?
                "is a file\n" : "is not a file\n" ) +
             ( name.isDirectory() ?
                "is a directory\n" : "is not a directory\n" ) +
             ( name.isAbsolute() ? "is absolute path\n" :
                "is not absolute path\n" ) +
             "Last modified: " + name.lastModified() +
             "\nLength: " + name.length () +
             "\nPath: " + name.getPath() +
             "\nAbsolute path: " + name.getAbsolutePath() +
             "\nParent: " + name.getParent() );
          // informa??o de sa?da se "name" ? um arquivo
          if ( name.isFile() ) {
             String nameString = String.valueOf(name.getPath());
             String nameTeste = new String(nameString);
             if (nameString.endsWith(".pdf"))
                 nameTeste = chamaConversor(nameString);
             else
                 if (nameString.endsWith(".doc"))
                     nameTeste = chamaConversorDoc(nameString); // chama conversor de arquivos DOC
                 else
                     if (nameString.endsWith(".txt"))
                         nameTeste = nameString;
             // se o arquivo termina com ".txt"           
             if (nameTeste.endsWith(".txt"))
                 // acrescenta conte?do do arquivo ? ?rea de sa?da
                 try {
                     // Create the tokenizer to read from a file
                     FileReader rd = new FileReader(nameTeste);
                     StreamTokenizer st = new StreamTokenizer(rd);
                     // Prepare the tokenizer for Java-style tokenizing rules
                     st.parseNumbers();
                     st.wordChars('_', '_');
                     st.eolIsSignificant (true);
                     // If whitespace is not to be discarded, make this call
                     st.ordinaryChars(0, ' ');
                     // These calls caused comments to be discarded
                     st.slashSlashComments(true);
                     st.slashStarComments(true);
                     // Parse the file
                     int token = st.nextToken();
                     String word_ant = "";
                     outputArea.append( " \n" );
                     out = new BufferedWriter(new FileWriter(nameTeste, true));
                     while (token != StreamTokenizer.TT_EOF) {
                         token = st.nextToken();
                         if (token == StreamTokenizer.TT_EOL){
                             //out.write(word);
                             out.flush();
                             out = new BufferedWriter(new FileWriter(nameTeste, true));
                             //outputArea.append( word + "\n" );
                             // out.append ( "\n" );
                         switch (token) {
                         case StreamTokenizer.TT_NUMBER:
                             // A number was found; the value is in nval
                             double num = st.nval;
                             break;
                         case StreamTokenizer.TT_WORD:
                             // A word was found; the value is in sval
                             word = st.sval;
                             //   if (word_ant.equals("a") || word_ant.equals("an") || word_ant.equals("the") || word_ant.equals("The") || word_ant.equals("An"))
                             outputArea.append( word.toString() + " \n " );
                            // out.append( word + "   " );
                             //     word_ant = word;
                             break;
                         case '"':
                             // A double-quoted string was found; sval contains the contents
                             String dquoteVal = st.sval;
                             break;
                         case '\'':
                             // A single-quoted string was found; sval contains the contents
                             String squoteVal = st.sval;
                             break;
                         case StreamTokenizer.TT_EOL:
                             // End of line character found
                             break;
                         case StreamTokenizer.TT_EOF:
                             // End of file has been reached
                             break;
                         default:
                             // A regular character was found; the value is the token itself
                             char ch = (char)st.ttype;
                             break;
                         } // fim do switch
                     } // fim do while
                     rd.close();
                     out.close();
                 } // fim do try
                 // process file processing problems
                 catch( IOException ioException ) {
                     JOptionPane.showMessageDialog( this,
                     "FILE ERROR",
                     "FILE ERROR", JOptionPane.ERROR_MESSAGE );
             } // fim do if da linha 92 - testa se o arquivo ? do tipo texto
          } // fim do if da linha 78 - testa se ? um arquivo
          // output directory listing
          else if ( name.isDirectory() ) {
                 String directory[] = name.list();
             outputArea.append( "\n\nDirectory contents:\n");
             for ( int i = 0; i < directory.length; i++ )
                outputArea.append( directory[ i ] + "\n" );
          } // fim do else if da linha 184 - testa se ? um diret?rio
       } // fim do if da linha 62 - testa se o arquivo existe
       // not file or directory, output error message
       else {
          JOptionPane.showMessageDialog( this,
             actionEvent.getActionCommand() + " Does Not Exist",
             "ERROR", JOptionPane.ERROR_MESSAGE );
    }  // fim do m?todo actionPerformed
    // m?todo que chama o conversor
    public String chamaConversor(String arquivoPdf){
        String arquivoTxt = new String(arquivoPdf);
        arquivoTxt = arquivoPdf.replace(".pdf", ".txt");
        try {
            conversor.pdfToText(arquivoPdf,arquivoTxt);
        catch (Exception ex) {
            ex.printStackTrace();
        return (arquivoTxt);
    // executa a aplica??o
    public static void main( String args[] )
       ConstrutorDeTemplate2 application = new ConstrutorDeTemplate2();
       application.setDefaultCloseOperation (
          JFrame.EXIT_ON_CLOSE );
    } // fim do m?todo main
}  // fim da classe ExtratorDeSubstantivos2
  * PdfToText.java
  * Created on 11 de Agosto de 2007, 10:57
  * To change this template, choose Tools | Template Manager
  * and open the template in the editor.
//package br.unifacs.dis2007.template2;
  * @author www
package br.unifacs.dis2007.template2;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL ;
import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.pdmodel.encryption.AccessPermission;
import org.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
import org.pdfbox.util.PDFText2HTML;
import org.pdfbox.pdmodel.font.PDFont.* ;
import org.pdfbox.util.PDFTextStripper;
import org.pdfbox.util.*;
import org.pdfbox.pdmodel.*;
public class PdfToText
    public void pdfToText( String pdfFile, String textFile) throws Exception
            Writer output = null;
            PDDocument document = null;
            try
                try
                    //basically try to load it from a url first and if the URL
                    //is not recognized then try to load it from the file system.
                    URL url = new URL( pdfFile );
                    document = PDDocument.load( url );
                    String fileName = url.getFile();
                    if( textFile == null && fileName.length () >4 )
                        File outputFile =
                            new File( fileName.substring( 0,fileName.length() -4 ) + ".txt" );
                        textFile = outputFile.getName();
                catch( MalformedURLException e )
                    document = PDDocument.load( pdfFile );
                    if( textFile == null && pdfFile.length() >4 )
                        textFile = pdfFile.substring( 0,pdfFile.length() -4 ) + ".txt";
                   //use default encoding
                  output = new OutputStreamWriter( new FileOutputStream( textFile ) );
                PDFTextStripper stripper = null;
                stripper = new PDFTextStripper();
                stripper.writeText( document, output );
            finally
                if( output != null )
                    output.close();
                if( document != null )
                    document.close();
            }//finally
        }//end funcao
 

You might have to modify you weblogic.policy to grant access rights for
WLAS.
Cheers - Wei
Nyman <[email protected]> wrote in message
news:[email protected]..
Hi everyone,
When running WLS in RedHat 6.2 with the command - ./startWebLogic.sh,an
error saying "Exception in thread mainjava.security.AccessControlException
: access denied (java.lang.RuntimePermission createSecurityManager) is
displayed.
Could anyone suggestion an solution?
Best Regardsm

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 with "Exception in thread "Thread-4" java.lang.NullPointerException"

    I am new to Java and I am trying a simple bouncing ball example from Stanford. Here is their simple example that works.
    import acm.program.*;
    import acm.graphics.*;
    import java.awt.*;
    public class BouncingBallWorking extends GraphicsProgram {
    /** sets diameter */
    private static final int DIAM_BALL = 30;
    /** amount y velocity is increased each cycle */
    private static final double GRAVITY = 3;
    /** Animation delay or pause time between ball moves */
    private static final int DELAY = 50;
    /** Initial X and Y location ball*/
    private static final double X_START = DIAM_BALL / 2;
    private static final double Y_START = 100;
    private static final double X_VEL = 3;
    private static final double BOUNCE_REDUCE = 0.9;
    private double xVel = X_VEL;
    private double yVel = 0.0;
    private GOval BallA;
    public void run() {
    setup(X_START,Y_START);
    //         Simulation ends when ball goes off right hand
    //         end of screen
    while (BallA.getX() < getWidth()) {
    moveBall(BallA);
    checkForCollision(BallA);
    pause(DELAY);
    private void setup(double X_coor, double Y_coor) {
    BallA = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
    add(BallA);
    private void moveBall(GOval BallObject) {
    yVel += GRAVITY;
    BallObject.move(xVel,yVel);
    private void checkForCollision(GOval BallObject) {
    if(BallObject.getY() > getHeight() - DIAM_BALL){
    yVel = - yVel * BOUNCE_REDUCE;
    double diff = BallObject.getY() - (getHeight() - DIAM_BALL);
    BallObject.move(0, -2 * diff);
    } Now I am trying to modify "setup" so it I can create several balls. I made a simple modification to "setup" and now I am getting an error.
    "Exception in thread "Thread-4" java.lang.NullPointerException
    at BouncingBallNotWorking.run(BouncingBallNotWorking.java:36)
    at acm.program.Program.runHook(Program.java:1592)
    at acm.program.Program.startRun(Program.java:1581)
    at acm.program.AppletStarter.run(Program.java:1939)
    at java.lang.Thread.run(Unknown Source)"
    Can you describe why I am getting an error? Thanks.
    Here is what I changed.
    Before:
         private void setup(double X_coor, double Y_coor) {
              BallA = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
              add(BallA);
         }After:
         private void setup(double X_coor, double Y_coor, GOval BallObject) {
              BallObject = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
              add(BallObject);
         }Here is the complete code.
    * File:BouncingBall.java
    * This program graphically simulates a bouncing ball
    import acm.program.*;
    import acm.graphics.*;
    import java.awt.*;
    public class BouncingBallNotWorking extends GraphicsProgram {
    /** sets diameter */
    private static final int DIAM_BALL = 30;
    /** amount y velocity is increased each cycle */
    private static final double GRAVITY = 3;
    /** Animation delay or pause time between ball moves */
    private static final int DELAY = 50;
    /** Initial X and Y location ball*/
    private static final double X_START = DIAM_BALL / 2;
    private static final double Y_START = 100;
    private static final double X_VEL = 3;
    private static final double BOUNCE_REDUCE = 0.9;
    private double xVel = X_VEL;
    private double yVel = 0.0;
    private GOval BallA;
    public void run() {
    setup(X_START,Y_START, BallA);
    //         Simulation ends when ball goes off right hand
    //         end of screen
    while (BallA.getX() < getWidth()) {
    moveBall(BallA);
    checkForCollision(BallA);
    pause(DELAY);
    private void setup(double X_coor, double Y_coor, GOval BallObject) {
    BallObject = new GOval(X_coor, Y_coor, DIAM_BALL, DIAM_BALL);
    add(BallObject);
    private void moveBall(GOval BallObject) {
    yVel += GRAVITY;
    BallObject.move(xVel,yVel);
    private void checkForCollision(GOval BallObject) {
    if(BallObject.getY() > getHeight() - DIAM_BALL){
    yVel = - yVel * BOUNCE_REDUCE;
    double diff = BallObject.getY() - (getHeight() - DIAM_BALL);
    BallObject.move(0, -2 * diff);
    } Edited by: TiredRyan on Mar 19, 2010 1:47 AM

    TiredRyan wrote:
    That is great! Thanks. I've got two question though.
    1.) Now I want to have 100 bouncing balls. Is the best way to achieve this is through an array of GOvals? I haven't gotten to the lecture on arrays on Stanford's ITunesU site yet so I am not sure what is possible with what I know now.An array would work, or a List. But it doesn't matter much in this case.
    2.) Are references being passed by value only applicable to Java or is that common to object-oriented programming? Also is there a way to force Java to pass in "BallA" instead of the value "null"?I can't say about all OO languages as a whole, but at least C++ can pass by reference.
    And no, there's no way to pass a reference to the BallA variable, so the method would initialize it and it wouldn't be null anymore.
    When you call the method with your BallA variable, the value of the variable is examined and it's passed to the method. So you can't pass the name of a variable where you'd want to store some object you created in the method.
    But you don't need to either, so there's no harm done.

  • 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" trouble

    I'm using NetBeans IDE 3.5.1 and every single program I've tried to write always comes out with, "java.lang.NoClassDefFoundError: (file name) Exception in thread "main" when I try to execute it. Here's a sample program;
    // Tests to see whether a floating point is zero or not
    class testZero{
    public static void main(String args[]) {
    float theNumber = 12;
    System.out.println(theNumber);
    What am I doing wrong?

    Apprently the file name of the .java file and the complied variant needs to be the same as the class the file contains.
    Yes, if the class is public. It's good practice always.
    Also, check out this document: http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html
    It covers naming conventions, which are a little different in Java if you have experience with another language. In accordance with these guidelines, your class should be named TestZero, not testZero. Following the standard naming conventions makes your code easier for other Java programmers to read and understand.

  • 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());

  • Exception in thread "main" javax.mail.NoSuchProviderException: invalid prov

    HI,
    I am trying to read mails from my inbox i amgetting the ErrorC:\javamail>java
    Readmail
    Exception in thread "main" javax.mail.NoSuchProviderException: No provider for IMAP
            at javax.mail.Session.getProvider(Session.java:455)
            at javax.mail.Session.getStore(Session.java:530)
            at javax.mail.Session.getStore(Session.java:510)
            at Readmail.main(Readmail.java:24)My Code is    {
    String host = "hostname";
    String username = "user";
    String password = "password";
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getDefaultInstance(props,null);
    // Get the store
    Store store = session.getStore("IMAP");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("Inbox");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++)
       System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    I have also tried POP3 and MIME and SMTP
    Can anyone help me Thanks

    hi bshannon,
    I am getting the same error for others but for pop3 the error is as below
    Exception in thread "main" javax.mail.MessagingException: Connect failed;
      nested exception is:
            java.net.ConnectException: Connection refused: connect
            at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148)
            at javax.mail.Service.connect(Service.java:275)
            at javax.mail.Service.connect(Service.java:156)
            at Readmail.main(Readmail.java:25)
    Caused by: java.net.ConnectException: Connection refused: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
            at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
            at java.net.Socket.connect(Socket.java:452)
            at java.net.Socket.connect(Socket.java:402)
            at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
            at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
            at com.sun.mail.pop3.Protocol.<init>(Protocol.java:81)
            at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)
            at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)
            ... 3 more

  • Exception in thread "AWT-EventQueue-0"  Invalid threat accces

    Hey,
    For my application I have created a menu in the system tray. When you click left you get some dynamic data and when you click right on my menu you get a screen to add a new dynamic menuitem to my system tray menu. but when I try to add something to that menu I get this error:
    Exception in thread "AWT-EventQueue-0" org.eclipse.swt.SWTException: Invalid thread access
    this is my code:
    import java.awt.Frame;
    import java.awt.Dimension;
    import javax.swing.JButton;
    import java.awt.BorderLayout;
    import javax.swing.SwingConstants;
    import java.awt.event.KeyEvent;
    import java.awt.Rectangle;
    import javax.swing.JTextField;
    import javax.swing.JLabel;
    import org.eclipse.swt.*;
    import org.eclipse.swt.graphics.*;
    import org.eclipse.swt.widgets.*;
    public class Test3 extends Frame {
         private static final long serialVersionUID = 1L;
         private JButton jButton = null;
         private JTextField txtInput = null;
         private JLabel lblInput = null;
         private JLabel lblResult2 = null;
         static Display display = new Display ();
         static Shell shell = new Shell (display);  //  @jve:decl-index=0:
         static MenuItem testMi = null;
          * This method initializes jButton     
          * @return javax.swing.JButton     
         private JButton getJButton() {
              if (jButton == null) {
                   jButton = new JButton();
                   jButton.setHorizontalTextPosition(SwingConstants.CENTER);
                   jButton.setMnemonic(KeyEvent.VK_UNDEFINED);
                   jButton.setBounds(new Rectangle(504, 246, 97, 29));
                   jButton.setText("Click");
                   //jButton.setSize(0,80);
                   //jButton.addActionListener(new java.awt.event.ActionListener());
                   jButton.addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseClicked(java.awt.event.MouseEvent e) {
                             //System.out.println("mouseClicked()"); // TODO Auto-generated Event stub mouseClicked()
                             lblResult2.setText(txtInput.getText());
                             testMi.setText("Dynamic");
                   //jButton.setRolloverEnabled(false);
                   //jButton.setPreferredSize(new Dimension(50, 10));
              return jButton;
          * This method initializes txtInput     
          * @return javax.swing.JTextField     
         private JTextField getTxtInput() {
              if (txtInput == null) {
                   txtInput = new JTextField();
                   txtInput.setBounds(new Rectangle(187, 73, 416, 22));
              return txtInput;
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              Test3 application = new Test3();
              application.initialize();
              application.setVisible(true);
              Image image = new Image (display, 16, 16);
              final Tray tray = display.getSystemTray ();
              if (tray == null) {
                   System.out.println ("The system tray is not available");
              else {
                   final TrayItem item = new TrayItem (tray, SWT.NONE);
                   item.setToolTipText("SWT TrayItem");
                   item.addListener (SWT.Show, new Listener () {
                        public void handleEvent (Event event) {
                             System.out.println("show");
                   item.addListener (SWT.Hide, new Listener () {
                        public void handleEvent (Event event) {
                             System.out.println("hide");
                   final Menu mainMenu = new Menu (shell, SWT.POP_UP);
                   for (int i =0; i <= 3; i++){
                        MenuItem mi = new MenuItem(mainMenu, SWT.PUSH);
                        mi.setText("Main Menu Item " + i);
                        mi.setEnabled(false);
                        if (i == 3 ){
                             mi.setEnabled(true);
                             mi.setText("Exit program");
                             mi.addListener(SWT.Selection, new Listener (){
                                  public void handleEvent (Event event){
                                       System.exit(0);
                   testMi = new MenuItem(mainMenu, SWT.PUSH);
                   testMi.setText("Static text");
                   item.addListener (SWT.Selection, new Listener () {
                        public void handleEvent (Event event) {
                             System.out.println("selection");
                             mainMenu.setVisible(true);
                   item.addListener (SWT.DefaultSelection, new Listener () {
                        public void handleEvent (Event event) {
                             System.out.println("default selection");
                   final Menu menu = new Menu (shell, SWT.POP_UP);
                   for (int i = 0; i < 8; i++) {
                        MenuItem mi = new MenuItem (menu, SWT.PUSH);
                        mi.setText ("Item" + i);
                        mi.addListener (SWT.Selection, new Listener () {
                             public void handleEvent (Event event) {
                                  System.out.println("selection " + event.widget);
                        if (i == 0) menu.setDefaultItem(mi);
                   item.addListener (SWT.MenuDetect, new Listener () {
                        public void handleEvent (Event event) {
                             menu.setVisible (true);
                   item.setImage (image);
              shell.setBounds(50, 50, 300, 200);
              shell.open ();
              while (!shell.isDisposed ()) {
                   if (!display.readAndDispatch ()) display.sleep ();
              image.dispose ();
              display.dispose ();
          * This is the default constructor
         public Test3() {
              super();
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
              lblResult2 = new JLabel();
              lblResult2.setBounds(new Rectangle(16, 117, 586, 30));
              lblResult2.setText("");
              lblInput = new JLabel();
              lblInput.setBounds(new Rectangle(13, 70, 168, 26));
              lblInput.setText(" Voer een lappie text in:");
              this.setLayout(null);
              this.setSize(627, 302);
              this.setTitle("Frame");
              this.setVisible(true);
              this.add(getJButton(), null);
              this.add(getTxtInput(), null);
              this.add(lblInput, null);
              this.add(lblResult2, null);
              this.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowClosing(java.awt.event.WindowEvent e) {
                        //lblResult2.setText("So you wanna close this window.. ;-) ");
                        System.exit(0);
    }  //  @jve:decl-index=0:visual-constraint="10,10"When you run this, you see a nice menu in the system tray..
    add some text in the screen that popup and click on save.. now you see the error.. (In this example ill try to change the static menu into a dynamic one)

    This is what I need for my application:
    - system tray menu
    - and some screens to infuence the system tray menu.. (add items to it, change setEnabled properties, etc)
    This is what I found on the Internet..
    Can you profide me (either an example or link to a page) where both is done?

  • "exception in thread main" error while running "dbca"

    Hi,
    i am getting following kind of error while trying to run dbca in linux.
    "exception in thread main"
    i have the dispaly env var set. and xhost+ set too. but still dbca is not working.
    i have pasted the contents of dbca file below. can someone have a look at the file and help me find the error.
    it would be great if someone can paste their dbca file content, so i can compare and fix the error.
    #!/bin/sh -f
    # $Header: dbca.sh 12-may-2005.11:05:03 xuliu Exp $
    # dbca.sh
    # Copyright (c) 1997, 2005, Oracle. All rights reserved.
    # NAME
    # dbassist - Shell script to run Database Creation Assistant
    # DESCRIPTION
    # Runs Database Creation Assistion java application
    # Run this script with -h or -help option to get the help.
    # MODIFIED (MMDD/YY)
    # npamnani 10/23/02 - add 1.3.1. java flag
    # npamnani 10/09/02 - run with java instead jre
    # dkapoor 07/05/2000 - Created
    # Variables set by Oracle Universal Installer for dependent components.
    # Define ORACLE_HOME -> OH
    OH=/home/oracle/oracle/product/10.2.0/db_1
    PLATFORM=Linux
    ORACLE_HOME=$OH
    export ORACLE_HOME;
    # Version specific JAR files
    JRE_FILE=rt.jar
    I18_FILE=i18n.jar
    EWT_FILE=ewt3.jar
    JEWT_FILE=jewt4.jar
    EWT_COMP_FILE=ewtcompat-3_3_15.jar
    SHARE_FILE=share.jar
    HELP_FILE=help4.jar
    #ICE_BROWSER_FILE=oracle_ice5.jar
    ICE_BROWSER5_FILE=oracle_ice5.jar
    KODIAK_FILE=kodiak.jar
    SWING_FILE=swingall-1_1_1.jar
    XMLPARSER_FILE=xmlparserv2.jar
    JDBC_FILE=classes12.zip
    GDK_FILE1=orai18n.jar
    GDK_FILE2=orai18n-mapping.jar
    GDK_FILE3=orai18n-utility.jar
    GDK_FILE4=orai18n-collation.jar
    NETCFG_FILE=netcfg.jar
    OJMISC_FILE=ojmisc.jar
    PKI_FILE=oraclepki103.jar
    LDAP_FILE=ldapjclnt10.jar
    OPM_FILE=opm.jar
    SRVM_FILE=srvm.jar
    SRVMHAS_FILE=srvmhas.jar
    SRVMASM_FILE=srvmasm.jar
    ASSISTANTS_COMMON_FILE=assistantsCommon.jar
    DBCA_FILE=dbca.jar
    EMLITE_JAR=oemlt-10_1_0.jar
    INSTALLER_FILE=OraInstaller.jar
    PREREQ_JAR_FILE=OraPrereq.jar
    PREREQ_CHECKS_JAR_FILE=OraPrereqChecks.jar
    # Directory Variables
    SRVM_JLIB_DIR=/home/oracle/oracle/product/10.2.0/db_1/jlib
    JRE_DIR=/home/oracle/oracle/product/10.2.0/db_1/jdk/jre
    LIB_DIR=$OH/lib
    LIB32_DIR=$OH/lib32
    JLIB_DIR=$OH/jlib
    DBCA_JLIB_DIR=$OH/assistants/dbca/jlib
    ASSISTANTS_JLIB_DIR=$OH/assistants/jlib
    INSTALLER_JLIB_DIR=/home/oracle/oracle/product/10.2.0/db_1/oui/jlib
    # Classpath
    JRE_CLASSPATH=$JRE_DIR/lib/$JRE_FILE
    I18_CLASSPATH=$JRE_DIR/lib/$I18_FILE
    EWT_CLASSPATH=$JLIB_DIR/$EWT_FILE:$JLIB_DIR/$EWT_COMP_FILE
    SHARE_CLASSPATH=$JLIB_DIR/$SHARE_FILE
    HELP_CLASSPATH=$JLIB_DIR/$HELP_FILE:$JLIB_DIR/$JEWT_FILE
    ICE_BROWSER_CLASSPATH=$JLIB_DIR/$ICE_BROWSER5_FILE
    KODIAK_CLASSPATH=$JLIB_DIR/$KODIAK_FILE
    SWING_CLASSPATH=$JLIB_DIR/$SWING_FILE
    XMLPARSER_CLASSPATH=/home/oracle/oracle/product/10.2.0/db_1/lib/$XMLPARSER_FILE
    JDBC_CLASSPATH=$OH/jdbc/lib/$JDBC_FILE
    GDK_CLASSPATH=$JLIB_DIR/$GDK_FILE1:$JLIB_DIR/$GDK_FILE2:$JLIB_DIR/$GDK_FILE3:$JLIB_DIR/$GDK_FILE4
    NETCFG_CLASSPATH=$JLIB_DIR/$NETCFG_FILE:$JLIB_DIR/$OJMISC_FILE:$JLIB_DIR/$PKI_FILE:$JLIB_DIR/$LDAP_FILE:$JLIB_DIR/$OPM_FILE
    SRVM_CLASSPATH=$SRVM_JLIB_DIR/$SRVM_FILE:$SRVM_JLIB_DIR/$SRVMHAS_FILE:$SRVM_JLIB_DIR/$SRVMASM_FILE
    EM_CLASSPATH=$OH/classes:$JLIB_DIR/$EMLITE_JAR:$JLIB_DIR/emca.jar:$OH/sysman/jlib/emCORE.jar:$OH/oc4j/j2ee/home/oc4j.jar:$OH/oc4j/j2ee/home/db_oc4j_deploy.jar:$JLIB_DIR/emConfigInstall.jar
    ASSISTANTS_COMMON_CLASSPATH=$ASSISTANTS_JLIB_DIR/$ASSISTANTS_COMMON_FILE
    DBCA_CLASSPATH=$DBCA_JLIB_DIR/$DBCA_FILE
    INSTALLER_CLASSPATH=$INSTALLER_JLIB_DIR/$INSTALLER_FILE:$INSTALLER_JLIB_DIR/$PREREQ_JAR_FILE:$OH/inventory/prereqs/oui/$PREREQ_CHECKS_JAR_FILE:$INSTALLER_JLIB_DIR/$PREREQ_CHECKS_JAR_FILE
    # Check for silent or help
    SILENT="false"
    for i in $*
    do
    if [ $i = "-silent"  ] || [ $i = "-help"  ] || [ $i = "-h"  ]; then
    SILENT="true"
    break
    fi
    done
    # Check for DISPLAY
    if [ $SILENT = "false"  ]; then
    case $DISPLAY in
    echo "DISPLAY not set."
    echo "Set DISPLAY environment variable, then re-run."
    exit;
    esac
    fi
    # make sure others can not read/write any files created
    umask 27
    # The environment variable $TWO_TASK cannot be set during the installation
    unset TWO_TASK
    # The environment variable $JAVA_HOME cannot be set during the installation
    unset JAVA_HOME
    # Basic error checking
    case $OH in
    "") echo "*** ORACLE_HOME Not Set!"
    echo " Set and export ORACLE_HOME, then re-run"
    echo " ORACLE_HOME points to the main directory that"
    echo " contains all Oracle products."
    exit 1;;
    esac
    # Set the LD_LIBRARY_PATH to set the path for shared objects
    # Do not set it on AIX
    if [ $PLATFORM != IBM_AIX ]; then
    LD_LIBRARY_PATH=$LIB32_DIR:$OH/network/lib32:$LIB_DIR:$OH/network/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH;
    fi
    # Set SHLIB_PATH for HP to use 32bit native libraries
    SHLIB_PATH=$LIB32_DIR:$ORACLE_HOME/network/lib32:$SHLIB_PATH
    export SHLIB_PATH;
    # Set LIBPATH for AIX to use 32bit native libraries
    LIBPATH=$LIB32_DIR:$ORACLE_HOME/network/lib32:$LIBPATH
    export LIBPATH;
    # Set Classpath for Database Creation Assistant
    CLASSPATH=$JRE_CLASSPATH:$I18_CLASSPATH:$DBCA_CLASSPATH:$ASSISTANTS_COMMON_CLASSPATH:$EWT_CLASSPATH:$SHARE_CLASSPATH:$HELP_CLASSPATH:$ICE_BROWSER_CLASSPATH:$KODIAK_CLASSPATH:$SWING_CLASSPATH:$XMLPARSER_CLASSPATH:$GDK_CLASSPATH:$NETCFG_CLASSPATH:$JDBC_CLASSPATH:$SRVM_CLASSPATH:$EM_CLASSPATH:$INSTALLER_CLASSPATH
    ARGUMENTS=""
    NUMBER_OF_ARGUMENTS=$#
    if [ $NUMBER_OF_ARGUMENTS -gt 0 ]; then
    ARGUMENTS=$*
    fi
    # Run DBCA
    $JRE_DIR/bin/java -Dsun.java2d.font.DisableAlgorithmicStyles=true -DORACLE_HOME=$OH -DDISPLAY=$DISPLAY -DJDBC_PROTOCOL=thin -mx128m -classpath $CLASSPATH oracle.sysman.assistants.dbca.Dbca $ARGUMENTS
    Thanks,
    Philip.

    I got this error also,.
    After restart the computer, it runs ok.

  • 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.

Maybe you are looking for