"Exception in thread "main" java.lang.NumberFormatException"error..pls help
Hi,
I'm trying to run a program I've written but keeping getting this error:
Exception in thread "main" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
at java.lang.Double.parseDouble(Double.java:482)
at data.newLineToRead(data.java:21)
at data.data(data.java:34)
at train.main(train.java:86)
I'm not quite sure where I'm going wrong.I've included the data class and train class.Could someone pls help me.
Thanks a lot.
Data Class:
import java.io.*;
import java.util.*;
public class data{
private static parameter par;
private static double[][] x=new double[par.n()][par.D()];
public static double[] t=new double[par.n()];
public static void newLineToRead(String LineToRead,int n){
int d=0;
String stringToRead=new String();
for(int i=0;i<=LineToRead.length();i++){
StringTokenizer str = new StringTokenizer (stringToRead,"/t");
String[] strtemp = new String[str.countTokens()];
while (str.hasMoreTokens()){
x[n][d++] = Double.parseDouble(str.nextToken());
d++;
System.out.println(x[n][d++]);
stringToRead=new String();
t[n]=Double.parseDouble(stringToRead);
x[n][par.d()]=1.0;
public static void data() throws IOException{
DataInputStream in=null;
try{
in=new DataInputStream(new FileInputStream(par.f()));
for(int n=0;n<par.n();n++){
String LineToRead=in.readLine();
if(LineToRead.length()==0){
System.out.println("Remove empty lines");
else{
newLineToRead(LineToRead,n);
}finally{if(in!=null){in.close();}}
public static double x(int n,int d){return x[n][d];}
public static double t(int n){return t[n];}
}Train Class
import java.io.*;
import java.util.*;
public class train{
private static parameter par;
private static data dat;
private static model mod;
private static response resp;
private static void error(String msg){
System.out.println(msg);
System.exit(1);
private static void check(){
if(par.f().length()==0)
error("No filename of input vectors!");
if(par.n()==0)
error("No number of input vectors!");
if(par.d()==0)
error("No number of input variables!");
if(par.d()>par.D())
error("Dimension is larger than 100!");
private static void usage(){
System.out.println("Non-default parameters==========================");
System.out.println("-f filename of input vectors");
System.out.println("-n number of input vectors");
System.out.println("-d number of input variables");
System.out.println("Default parameters==========================");
System.out.println("-R regularisation constant (must be positive and the default value is 0.0)");
System.out.println("-S epsilon criterion for stopping a learning process (default value is 0.001)");
System.out.println("-C maximum learning cycle (default value is 10000)");
public static void main(String[] argv){
if(argv.length==0){
System.out.println("Command line is <Java [-cp path] train parameters>");
usage();
System.exit(1);
if(argv.length==1 && argv[0].equals("help")==true){
usage();
System.exit(1);
par.nin(0); par.din(0); par.Rin(0.0); par.Cin(10000); par.Sin(0.001);
for(int i=0;i<argv.length;i++){
if(argv.equals("-f")==true){
if((i+1)==argv.length)
error("miss the para");
par.fin(argv[i+1]);
i++;
else if(argv[i].equals("-d")==true){
if((i+1)==argv.length)
error("miss the para");
par.din(Integer.parseInt(argv[i+1]));
i++;
else if(argv[i].equals("-n")==true){
if((i+1)==argv.length)
error("miss the para");
par.nin(Integer.parseInt(argv[i+1]));
i++;
else if(argv[i].equals("-S")==true){
if((i+1)==argv.length)
error("miss the para");
par.Sin(Integer.parseInt(argv[i+1]));
i++;
else if(argv[i].equals("-C")==true){
if((i+1)==argv.length)
error("miss the para");
par.Cin(Integer.parseInt(argv[i+1]));
i++;
else if(argv[i].equals("-R")==true){
if((i+1)==argv.length)
error("miss the para");
par.Rin(Double.parseDouble(argv[i+1]));
i++;
else error("Unkown token");
check();
try {
dat.data();
}catch(IOException e) { System.err.println(e.toString()); }
try {
mod.model();
}catch(IOException e) { System.err.println(e.toString()); }
try {
resp.record();
}catch(IOException e){ System.err.println(e.toString()); }
String stringToRead=new String();
for(int i=0;i<=LineToRead.length();i++){
StringTokenizer str = new StringTokenizer (stringToRead,"/t");
String[] strtemp = new String[str.countTokens()];
while (str.hasMoreTokens()){
x[n][d++] = Double.parseDouble(str.nextToken());
d++;
System.out.println(x[n][d++]);
stringToRead=new String();
t[n]=Double.parseDouble(stringToRead);
x[n][par.d()]=1.0;
}Not sure exactly what you are trying to do above but...
You are setting your String to an empty String with "new String()" and then parsing that empty String. Eventually, you are trying to parse a double from that empty String:
t[n]=Double.parseDouble(stringToRead);Also, I cannot think of a reason to ever use "new String()" when you could just use:
String myString = "";
Similar Messages
-
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.UnsupportedClassversion error.
hi,
I am having the JDk and jre versions in C: drive
i am jdk version 1.5.0
but when i am running the command version it is showing 1.4.2_03 version and also i am having the oracle 10g on my system.
tried seeting classpath also but no success.
I am trying to run a simple helloworld program.while compiling there seems to be no problem..
But while running the program i am encountring the following error.
Exception in thread "main" java.lang.UnsupportedClassversion error.
can someone help me regarding thisClasspath is NOT going to help. You may be able to fix this by putting the JDK bin directory as the first entry in your system's PATH variable.
-
"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.NullPointerException error JDeveloper 12c
Hello,
I am trying to call a java stored procedure in java application. I am using ORACLE database and JDeveloper.
I am getting error "Exception in thread "main" java.lang.NullPointerException. I have no idea what have I been doing wrong.
I have a table "Beer" and I want to select all the data out with a stored procedure which I call out of Java app.
I have a java.class file Store_A.java which I have loaded into the ORACLE database with LOADJAVA :
import java.sql.*;
import java.io.*;
public class Store_a {
public static void apskatit ()
throws SQLException
{ String sql =
"SELECT * FROM Beer";
try { Connection conn = DriverManager.getConnection("jdbc:default:connection:");
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rset = pstmt.executeQuery();
rset.close();
pstmt.close();
catch (SQLException e) {System.err.println(e.getMessage());
Then I have created a procedure which I plan to call out in java:
CREATE OR REPLACE PACKAGE Store_a AS
PROCEDURE apskatit;
END Store_a;
CREATE OR REPLACE PACKAGE BODY Store_a AS
PROCEDURE apskatit AS LANGUAGE JAVA
NAME 'Store_a.apskatit()';
END Store_a;
And I have a java file that I have created with JDeveloper 12c:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Class1 {
* @param args
public static void main(String[] args) throws SQLException {
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//Izveidojam savienojumu
conn = DriverManager.getConnection("jdbc.oracle.thin:@localhost:1521", "SYSTEM", "asdasd");
// Izveidojam callable statement
CallableStatement stmt = conn.prepareCall("CALL Store_a.apskatit()");
ResultSet resul = stmt.executeQuery();
while (resul.next()) {
System.out.println(resul.getInt(1) + "\t" + resul.getString(2));
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
When I try to run the java file, I get this error "Exception in thread "main" java.lang.NullPointerException at client.Class1.main(Class1.java:29).
So the line I get error in is "conn.close();"
How to fix this?
Thank you very much in advance.I am trying to call a java stored procedure in java application. I am using ORACLE database and JDeveloper.
I am getting error "Exception in thread "main" java.lang.NullPointerException. I have no idea what have I been doing wrong.
Maybe you haven't read it yet but I told you in your other thread what you were doing wrong and, step by step, how to address the problem.
https://forums.oracle.com/thread/2611124
I'm not going to repeat everything again just this one main piece of advice:
Until you get you code working outside the database don't even bother trying to load it into the DB and create a Java stored procedure.
You are trying to deal with too many different issues at the same time. Unless you solve your primary Java problem by fixing the code outside the DB you will have nothing but problems loading it into the DB.
And just get rid of this line of code - you don't need it anymore and it hasn't been done like that for many years now:
Class.forName("oracle.jdbc.driver.OracleDriver"); -
Exception in thread "main" java.lang.UnsatisfiedLinkError ERROR
Hi All,
I am trying to develop a Swing Application. I have compiled my codes in Windows like this:
javac -d ../../classes *.javaThen I tried to run the program from <my dir>/classes/ folder...
java com.fusion.ucmrtnd.Mainwhere Main.java contains the main() method.
But I am getting the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.awt.SunToolkit.getAppContext(Ljava/lang/Object;)Lsun/awt/AppContext;
at sun.awt.SunToolkit.getAppContext(Native Method)
at sun.awt.SunToolkit.targetToAppContext(Unknown Source)
at sun.awt.windows.WComponentPeer.postEvent(Unknown Source)
at sun.awt.windows.WComponentPeer.replaceSurfaceDataLater(Unknown Source)
at sun.awt.windows.WWindowPeer.updateInsets(Native Method)
at sun.awt.windows.WWindowPeer.initialize(Unknown Source)
at sun.awt.windows.WFramePeer.initialize(Unknown Source)
at sun.awt.windows.WComponentPeer.<init>(Unknown Source)
at sun.awt.windows.WCanvasPeer.<init>(Unknown Source)
at sun.awt.windows.WPanelPeer.<init>(Unknown Source)
at sun.awt.windows.WWindowPeer.<init>(Unknown Source)
at sun.awt.windows.WFramePeer.<init>(Unknown Source)
at sun.awt.windows.WToolkit.createFrame(Unknown Source)
at java.awt.Frame.addNotify(Unknown Source)
at javax.swing.SwingUtilities$SharedOwnerFrame.addNotify(Unknown Source)
at java.awt.Dialog.addNotify(Unknown Source)
at java.awt.Dialog.conditionalShow(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at DisplayStrip.DisplayStripRun(DisplayStrip.java:32)
at Main.main(Main.java:8)PS: I used NetBeans 6.5 IDE, where it's working fine. But when I am trying to deploy the codes in Windows, I am getting this error.
Any help would be appreciated.
TiA....maybe your rt.jar conflicting
-
Exception in thread "main" java.lang.ClassFormat Error
I am running a java program in NeBeans and when I run the program I am getting the following error:
Exception in thread "main" java.lang.ClassFormatError: Repetitive method name/signature in class file pluginex2/TtsoapcgiPortType_addLink_ResponseStruct_SOAPSerializer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at pluginex2.Ttsoapcgi_SerializerRegistry.getRegistry(Ttsoapcgi_SerializerRegistry.java:73)
at pluginex2.Ttsoapcgi_Impl.<init>(Ttsoapcgi_Impl.java:25)
at pluginex2.Main.main(Main.java:25)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
What should I do?Can anyone please help me out?
Thanks,
Sravanthi.The class files are automatically into the build/generated/wsclient/project-name file of my project.
I copied those class files into my source folder to make my program work.When I searched my system I jus found two of these files in build/generated/wsclient/project-name folder and source folder of my project.
I am running the program directly through NetBeans IDE. -
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()); -
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. -
Exception in thread "main" java.lang.ArrayIndexIndexOutOfBoundsException: 0
I have a method that stores int array values when the method is called, here is the method code:
public static void statArray()
int c = 0;
int dStat = 0;
//Player stats
int[] s1 = new int[count1];
int[] s2 = new int[count2];
if(playing == true)
if(player == 1)
s1[sN1] = roll1;
++count1;
++sN1;
if(player == 2)
s2[sN2] = roll2;
++count2;
++sN2;
if(playing == false)
clear();
while(c < 15 && played == true)
extra.center("Your Score");
extra.center("Roll " + dStat + ": " + s1[dStat]);
++dStat;
++c;
if(played == false)
extra.center("You have no stats because you have not yet played the game!");
extra.center("\n\n\n\n\n\n\n");
else
extra.center("Sorry there was an error!");
extra.center("");
extra.center("Please press enter to go to the main menu");
In.getChar();
printMenu();
}However I keep getting a run time error of: Exception in thread "main" java.lang.ArrayIndexIndexOutOfBoundsException: 0
Please Help.On which line does the error occur? And what is the value of count1 and count2? If they happen to be zero you'll have an array with zero items, so any index will be out of bounds.
-
Dear,
I have "test" class:
public class test{
public static void main(String argv[]){
System.out.println("Hello world!");
I use below command to compiler & run this class:
C:\> javac test.java
There is no problem and I get file: test.class
After that, I use:
C:\> java test
I meet this message and the class cannot be run:
Exception in thread "main" java.lang.NoClassDefFoundError: test
Please help me to solve this problem.
Regards,
Cuong Habefore running set classpath
like this type in command prompt
suppose this class file in in folder c:\abc
set classpath=%classpath%;C:\abc\
and now run ur code
or
i think this is better solution not try aboce try this first
before running
type this
set path=%path%;c:\jdk1.3\bin
where 'c:\jdk1.3\bin' is the path where ur jdk is installed -
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. -
Hi,
system i am using for Oracle SOA is :
Windows 64 Bit
i5 Processor
6 GB RAM
29 GB on C Drive is already free after installation of all SOA related products.
I have installed wlserver_10.3 for SOA 11g Development purpose and followed exact installation sequence and procedure as mention in oracle documentation
i created domain also and every thing look correct but after installation procedure there are "Additional actions required just after every thing installed" :
setting memory limit
starting weblogic server (Admin Server)
starting weblogic managed server
and so on
now Problem is when i execute C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin startWebLogic.cmd
as mention in oracle documentation i am getting following error message : (i have only included last error lines instead of complete console log)
oConsole= -Dweblogic.ext.dirs=C:\Oracle\MIDDLE~1\patch_wls1036\profiles\default\
sysext_manifest_classpath;C:\Oracle\MIDDLE~1\patch_oepe180\profiles\default\syse
xt_manifest_classpath;C:\Oracle\MIDDLE~1\patch_ocp371\profiles\default\sysext_ma
nifest_classpath;C:\Oracle\MIDDLE~1\patch_adfr1111\profiles\default\sysext_manif
est_classpath weblogic.Server
Listening for transport dt_socket at address: 8453
Exception in thread "main" java.lang.NoClassDefFoundError: vXmx512m
Caused by: java.lang.ClassNotFoundException: vXmx512m
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: ++Xmx512m. Program will exit.
Now to resolve this what i already tried are :
I change JAVA_HOME and PATH to jdk6 which came with web logic installer
Location is at :
JAVA_HOME : C:\Oracle\Middleware\jdk160_29
PATH : C:\Oracle\Middleware\jdk160_29\bin
The above dose not include any space between path
I ran the startWebLogic.cmd and got same error
After that I also added
CLASSPATH : C:\Oracle\Middleware\jdk160_29\lib\tool.jar;C:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\jdk160_29\bin
WL_HOME: C:\Oracle\Middleware\wlserver_10.3
I ran the startWebLogic.cmd and got same error
I also used earlier path which I used with eclipse when I was working on other java development.
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_21
PATH : C:\Program Files\Java\jdk1.7.0_21\bin
I ran the startWebLogic.cmd and got same error
Then I also gave PATH: C:\Oracle\Middleware\wlserver_10.3\server\lib (including the existing one using ; )
I ran the startWebLogic.cmd and got same error
Now may be there is a file called setSOADomainEnv.cmd in
< C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin\ setSOADomainEnv.cmd>
That include some values for memory set :
set JAVA_OPTIONS=%JAVA_OPTIONS%
set DEFAULT_MEM_ARGS=-Xms512m –Xmx512m
set PORT_MEM_ARGS=-Xms512m –Xmx768m
if "%JAVA_VENDOR%" == "Oracle" goto OracleJVM
set DEFAULT_MEM_ARGS=%DEFAULT_MEM_ARGS% -XX:PermSize=128m -XX:MaxPermSize=768m
set PORT_MEM_ARGS=%PORT_MEM_ARGS% -XX:PermSize=256m -XX:MaxPermSize=768m
now as I change the red highlighted value to 512 value because I have less memory resource and I checked in installation documentation to change the above red highlighted value to 512 original is 1024 which is too high and it was crating problem and showing memory space problem so I change it to 512 and now I am not getting that memory space problem error but may be the above error is related with change value in setSOADomainEnv.cmd file or not
Following are my domain, weblogic and soa home directory path and all these path are exactly what it suppose to be according to Oracle Installation Documentation:
WebLogic :
C:\Oracle\Middleware\wlserver_10.3
C:\Oracle\Middleware\coherence_3.7
C:\Oracle\Middleware\oepe_11.1.1.8.0
SOA Oracle Home Directory :
C:\Oracle\Middleware\Oracle_SOA1
OSB Home Location :
C:\Oracle\Middleware\Oracle_OSB1
Domain name : soa_div_domain
Domain Location : C:\Oracle\Middleware\user_projects\domains
Application Location : C:\Oracle\Middleware\user_projects\applications
Domain Location: C:\Oracle\Middleware\user_projects\domains\soa_div_domain
form here i am trying to start weblogic : C:\Oracle\Middleware\user_projects\domains\soa_div_domain\bin\startWebLogic.cmd
Please tell me any body want more details.
Thanks.I think you are missing a character '-'
USER_MEM_ARGS="Xms512m -Xmx512m -XX:MaxPermSize=128m"Add this character like follows
"-Xms512m -Xmx512m -XX:MaxPermSize=128m" -
Hi all,
i try to use pfi with a project that i did with air in flash builder.
I make my swf with ant task
<target name="releasecompile" depends="init">
<echo>
Ant Task :: releaseCompile
</echo>
<java jar="${MXMLC.JAR}" fork="true" failonerror="true">
<arg value="-debug=false"/>
<arg value="+flexlib=${SDK_HOME}frameworks"/>
<arg value="+configname=air"/>
<arg value="-file-specs=${MAIN_SOURCE_FILE}"/>
<arg value="-output=${build}/${APP_ROOT_FILE}"/>
<arg value="-external-library-path+=${APP_ROOT}/libs/PureMVC_AS3_MultiCore_1_0_5.swc" />
</java>
</target>
i have a swf in result and i play pfi like this
./pfi -package -target ipa-ad-hoc -provisioning-profile /Users/stef/Desktop/PROJECT/PROJECT_Config-2.mobileprovision -storetype pkcs12 -keystore /Users/stef/Desktop/PROJECT/Certificats2.p12 -storepass mypass /Users/stef/Desktop/PROJECT/PROJECTConfig.ipa /Users/stef/Documents/Adobe\ Flash\ Builder\ 4/PROJECT/src/PROJECTConfigurateur-app.xml -C /Users/stef/Desktop/PROJECT/ PROJECTConfigurateur.swf Default.png icons/Icon57.png icons/Icon29.png icons/Icon512.png
Exception in thread "main" java.lang.Error: Unable to find named traits: org.puremvc.as3.multicore.patterns.facade::Facade
at adobe.abc.Domain.resolveTypeName(Domain.java:195)
at adobe.abc.Domain.resolveTypeName(Domain.java:112)
at adobe.abc.GlobalOptimizer$InputAbc.resolveTypeName(GlobalOptimizer.java:274)
at adobe.abc.GlobalOptimizer$InputAbc.readInstance(GlobalOptimizer.java:837)
at adobe.abc.GlobalOptimizer$InputAbc.readAbc(GlobalOptimizer.java:388)
at adobe.abc.GlobalOptimizer$InputAbc.readAbc(GlobalOptimizer.java:280)
at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:160)
at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcode(AOTCompiler.java:329)
at com.adobe.air.ipa.AOTCompiler.GenerateMacBinary(AOTCompiler.java:600)
at com.adobe.air.ipa.IPAOutputStream.compileRootSwf(IPAOutputStream.java:196)
at com.adobe.air.ipa.IPAOutputStream.finalizeSig(IPAOutputStream.java:366)
at com.adobe.air.ADTPackager.createPackage(ADTPackager.java:65)
at com.adobe.air.ipa.IPAPackager.createPackage(IPAPackager.java:165)
at com.adobe.air.ADTEntrypoint.parseArgsAndGo(ADTEntrypoint.java:132)
at com.adobe.air.ipa.PFI.parseArgsAndGo(PFI.java:152)
at com.adobe.air.ADTEntrypoint.run(ADTEntrypoint.java:68)
at com.adobe.air.ipa.PFI.main(PFI.java:112)
do you have some ideas about this ?
Regards
StefOk,
<target name="releasecompile" depends="init">
<echo>
Ant Task :: releaseCompile
</echo>
<java jar="${MXMLC.JAR}" fork="true" failonerror="true">
<arg value="-debug=false"/>
<arg value="+flexlib=${SDK_HOME}frameworks"/>
<arg value="+configname=air"/>
<arg value="-file-specs=${MAIN_SOURCE_FILE}"/>
<arg value="-output=${build}/${APP_ROOT_FILE}"/>
<arg value="-external-library-path+=${APP_ROOT}/libs/PureMVC_AS3_MultiCore_1_0_5. swc" />
</java>
</target>
I mistake this line
<arg value="-external-library-path+=${APP_ROOT}/libs/PureMVC_AS3_MultiCore_1_0_5. swc" />
must be
<arg value="-library-path+=${APP_ROOT}/libs/PureMVC_AS3_MultiCore_1_0_5.swc" />
for include the content in the swf.
Regards
Stef
Maybe you are looking for
-
How can I export a Group in Contacts to an Excel spreadsheet ? I've tried to follow the instructions but am going in circles: I opened the Group, then 'selected" all contacts in the Group, then chose File>Export>Export vCard. Saved it to Desktop, bu
-
Problems viewing a sheet on original macbook air
i have created a spreadsheet using numbers on my macbook pro (mt. Lion) and saved it to a usb drive to use with my macbook air (original) running mt lion. When I open the file on the air, numbers encounters no problems and opens the document with all
-
ITunes 7 for Windows Vista: AirTunes won't connect to remote speakers
HELP!! Everything was working fine, until 2 weeks ago, when suddenly, my airtunes wouldn't connect to my remote speakers! The little button at the bottom of itunes, which gives you the option of listening to music through your computer or the base st
-
Flash CC Air iOS: Problems with loading text from an external xml located on a server.
So I have this code allowing me to load text from an xml located on a server. Everything works fine on the Air for Android. The app even works in the ios emulator, but once I export my app to my ios device with ios 7, I don't see any text. The app is
-
Equivalent of dateadd(MS Acess) in oracle
I want the equivalent of (DateAdd("s",[OBJ_M_DOCUMENTS.M_DOC_N_DATE],"12/15/1970")) which is Acess in oracle. [OBJ_M_DOCUMENTS.M_DOC_N_DATE] is the column name.