OUI is not openinig. Exception in thread "main" java.lang.NoClassDefFound
hi.
while i'm trying to install oracle server, getting the below error
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 80 MB. Actual 9277 MB Passed
Checking swap space: must be greater than 150 MB. Actual 3529 MB Passed
Checking monitor: must be configured to display at least 256 colors
>>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<<
Some requirement checks failed. You must fulfill these requirements before
continuing with the installation,
Continue? (y/n) [n] y
Ignoring required pre-requisite failures. Continuing...Preparing to launch Oracle Universal Installer from /tmp/OraInstall2012-09-27_02-55-33AM. Please wait ...[satish@rac1 database]$ Exception in thread "main" java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at java.awt.Toolkit$2.run(Toolkit.java:821)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:804)
at com.jgoodies.looks.LookUtils.isLowResolution(Unknown Source)
at com.jgoodies.looks.LookUtils.<clinit>(Unknown Source)
at com.jgoodies.looks.plastic.PlasticLookAndFeel.<clinit>(PlasticLookAndFeel.java:122)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1783)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:480)
at oracle.install.commons.util.Application.startup(Application.java:758)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:164)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:265)
at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:114)
at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:132)
hi Srini,
thanks for your time.
I am trying to install it on RHEL 5 on VMWare Player, and the db version is 11g.
i think the problem is with the below error
Exception in thread "main" java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at java.awt.Toolkit$2.run(Toolkit.java:821)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:804)
at com.jgoodies.looks.LookUtils.isLowResolution(Unknown Source)
at com.jgoodies.looks.LookUtils.<clinit>(Unknown Source)
at com.jgoodies.looks.plastic.PlasticLookAndFeel.<clinit>(PlasticLookAndFeel.java:122)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1783)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:480)
at oracle.install.commons.util.Application.startup(Application.java:758)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:164)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:265)
at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:114)
at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:132)
Similar Messages
-
"Exception in thread "main" java.lang.NoClassDefFound Error" in XP
I was creating programs just fine for awhile. Then, for some unknown reason, I start getting the runtime error message, "Exception in thread "main" java.lang.NoClassDefFound Error." I set my PATH in the following manner:
Start | Control Panel | Performance and Maintenance | System | Advanced | Environment Variables | Use Variables for Owner | PATH | Edit | C:\j2sdk1.4.2_04;C:\j2sdk1.4.2_04\bin;C:\j2sdk1.4.2_04\jre\bin | Ok | Ok | Ok
I then closed the dialog boxes and restarted my computer. I then tried to run a program that ran before, only to get the same runtime error! Can someone please help me???NoClassDefFoundError happens because the JVM cannot find some class from your program, not because the OS cannot find your JVM (PATH regulates the latter, but not the former). JVM looks up classes in directories (or JAR files) specified through the -classpath option, like "java -classpath c:\myclasses MyMainClass". Read the online doc for the "java" launcher for more info.
-
Error:"exception in thread main:java.lang.noclassdeffound error.
Hi,
I am new to this java tech and programming. I just started learning and installed j2sdk1.4.0_03. I wrote a small hello world program and compiled it without any errors. When I execute the same using java hello command, I am getting an error like this: exception in thread "main" java.lang.noclassdeffound error. I am not able to resolve this issue. Please let me know the sol.
thanks
venkatramansend the program u have typedUmm... Why?
Anyway @NovaKane: Welcome. Together with seifist and sunny we have at
least three new posters who show enough intelligence to find chuck's
solution (or one of the many hundreds of others like it) and the politeness
to thank him for it. What's the forum coming to?
If you need it there is a description of the classpath here:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html
Again, welcome. And thanks for raising the intelligence level (and politeness
quotient) of the fora. -
Exception in thread "main" java.lang.NoClassDefFound
C:\myjava>java JdbcCheckup
Exception in thread "main" java.lang.NoClassDefFoundError: JdbcCheckup
C:\myjava>java -cp %CLASSPATH%; . JdbcCheckup
Exception in thread "main" java.lang.NoClassDefFoundError: c:\tomcat_4\common\li
b\servlet/jar;
C:\myjava>
here is my classpath. There is 'c:\tomcat_4\common\lib\servlet/jar;' its listed as a .jar file?
why cant i compile?
CLASSPATH=c:\oracle\ora81\jdbc\lib\classes12.zip; c:\tomcat_4\common\lib\serv
t.jar; c:\eclipse; c:\tomcat_4\examples\WEB-INF\classes;c:\oracle\ora81\jlib\b
raphbean.jar;c:\oracle\ora81\jlib\LW_PfjBean.jar;c:\oracle\ora81\jlib\bigraphb
n-nls.zipEither remove the erroneous spaces between your classpath elements, or do:
java -cp "%CPASSPATH";." JdbcCheckup
(notice the double-quotes)
The way you did it, as soon as it saw the first space (after your classes12.zip entry), it thought that was the end of the classpath. -
"Exception in thread "main" java.lang.NoClassDefFound: classname" error.
Here's my code:
public class Hello
public static void main( String[] args )
System.out.println( "Hello!" );
it compiles but it wont run. it encounters this error: " Exception in thread "main" java.lang.NoClassDefFoundError: Hello"
Since I am using jdk1.3, my path is "c:\windows;c:\windows\command;c:\progra~1\dell\resolu~1\common\bin;c:\jdk1.3\bin"
another error I noticed in my computer were these while running Calculator.java:
Calculator.java:11: cannot resolve symbol
symbol: class Calc
location: class Calculator
Calc calculator;
Calculator.java:36: cannot resolve symbol
symbol: class Calc
location: class Calculator
calculator = new Calc();
2 errors
Yet my Calculator.java, Calculator.class, Calc.java, Calc.class, Calculator.html files are all in one folder.
Since I am using jdk1.3, my path is "path=c:\windows;c:\windows\command;c:\progra~dell\resolu~1\common\bin;c:\jdk1.3\bin;"
I would greatly appreciate your help.
Thank you very much!=)hi!
set the classpath to the relative path "."!
in the command box type this:
SET CLASSPATH=.;
then it should work!
visit: >> http://www.menzsoft.ch <<
greets -
The following Error: Exception in thread "main" java.lang.NoClassDefFoundE
Dear People,
I would really kindly welocme any help on the following error problem:
Exception in thread "main" java.lang.NoClassDefFoundError: CoreUpdate
The program compiles successfully and there are no errors generated from that but I get the above error when I try to run it. I have scanned over all the previous replies that have been posted for this sort of error and have tried all the following solutions:
1) Set classpath to point to the bin and lib directories of where the JDK1.3.1 is installed in.
2) Have actually placed in my classpath the EXACT directory to which the tools.jar file is located (within the lib directory).
So WHAT ELSE is there to do?? I am really frustrated with this problem and I have re-started my computer in order to boot the classpath into gear but still no joy!
I am running Win2k so do I actually have to go into my autoexec.bat file and type the classpath in there aswell(to which I havent done) or can I just go through my computer on my desktop and then to environment variables and set it up in there (to which I have done already and nopthing seems to work)?
PLEASE PLEASE PLEASE help!! I very frustated girl programmer!!!
Any help would be very much appreciated!
Regards
Helen PringleSorry about that last email - this is the errors I get now after I have placed that '.' to my classpath!
The program is trying to access a MySQL DB.
java.lang.ClassNotFoundException: org.gyt.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:124)
at CoreUpdate.main(CoreUpdate.java:13)
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:477)
at java.sql.DriverManager.getConnection(DriverManager.java:159)
at CoreUpdate.main(CoreUpdate.java:24)
Regards
Helen -
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. -
Hi All,
Getting the above error when running the following export utility:
$ java oracle/apex/APEXExport
ABove error is thrown.
I have looked at most blogs suggested by ML.
Here are my env params:
echo $CLASSPATH
/u01/app/oracle/product/11.2.0/db_1/jdbc/lib/ojdbc5dms.jar
( No, i don't see any classes12.jar. The classes12.zip resides in oui folder. I tried that as well and it didnt work)
echo $JAVA_HOME
/usr/java/jdk1.7.0_02
So for the heck of it, I tried:
$ export CLASSPATH=.:${ORACLE_HOME}/jdbc/lib/classes12.zip
and lo, I am able to at least summon this:
$ java oracle/apex/APEXExport
Usage APEXExport -db -user -password -applicationid -workspaceid -instance -skipExportDate -expSavedReports -debug
-db: Database connect url in JDBC format
-user: Database username
-password : Database password
-applicationid : ID for application to be exported
-workspaceid : Workspace ID for which all applications to be exported
-instance : Export all applications
-skipExportDate : Exclude export date from application export files
-expSavedReports: Export all user saved intera
BUT: when invoking specific job, I get this:
java oracle/apex/APEXExport -db hostname:1521:SID -user apex_030200 -password welcome123 -instance
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at oracle.apex.APEXExport.main(APEXExport.java:315)
any ideas?Hello,
I get a very similar error.
Windows 7 Ultimate SP1
Oracle XE 11.2
Apex 4.1
jdk 6u31-windows x64.exe (installed to C:\Program Files\Java\jdk1.6.0_31\.....)
User Variable CLASSPATH = .\; C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar
User Variable JAVA_HOME = C:\program files\java\jdk1.6.0_31\jre\bin
User Variable ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server
System Variable PATH = C:\oraclexe\app\oracle\product\11.2.0\server\bin;;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\11.0\DLLShared\;C:\Program Files (x86)\Pinnacle\Shared Files\;C:\Program Files (x86)\Pinnacle\Shared Files\Filter\;C:\Program Files (x86)\QuickTime\QTSystem\
At the C:\apex\utilities directory I give the command:
java oracle.apex.APEXExpress -db localhost:1521:XE -user SUSANNA -password skippy123 -expworkspace
I get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/apex/APEXExpress
Caused by: java.lang.ClassNotFoundException: oracle.apex.APEXExpress
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doProvileged(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: oracle.apex.APEXExpress. Program will exit. -
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
helpWhen 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. -
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? -
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
-
Hi, Is it possible to send e-mail campaigns through Webmail, but still obtain e-mail campaign reports through Business Catalyst? I have some e-mail lists that I can only access through webmail, but require the reporting features that Business Catalys
-
Purchase Info Records ( ME11)
Hi all, I am trying post Data for Purchase Info Records with Conditions data. I am using a standard Batch Input Method ( LSMW). Object 0060 Method 0000 Program Name RM06IBI0 Program Type B Batch Input I
-
Exclusion of cash in advance in credit check
Dera All, My requirement is to exclude the Letters of credit amount, cash against documents and demand draft amount in credit exposure amount of a customer. The system should take the above amounts in the Credit exposure. I dont get the clue for maki
-
Half Day LOP / Unpaid Absence not working for payroll india
Dear Gurus, I have created Unpaid leave which is working correctly when we maintain full day absence in infotype 2001. But it is not working for partial absence ie, half day. I would really appreciate if you help me out on this issue. Thanks, Rajesh
-
Finding the link for adobe 9 pro download?
I am looking for a link to download adobe 9 pro. I have my license number but lost the disk.