Exception in thread "main" java.lang.NullPointerException怎么解决??? [问题点数:40分,结帖人wanwangzi]

Bbs1
本版专家分:0
结帖率 100%
Bbs4
本版专家分:1492
Bbs3
本版专家分:734
Bbs1
本版专家分:0
Bbs4
本版专家分:1492
Bbs1
本版专家分:0
main" java.lang.NullPointerException">Exception in thread "main" java.lang.NullPointerException
希望高手指点
main" java.lang.NullPointerException问题">Exception in thread "main" java.lang.NullPointerException问题
Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerException 该问题多半是由于用到的某个对象只进行了声明,而没有初始化,即没有被new 比如说: 一个类Person,有一个对象p1 声明对象 Person p1; 使用该对象(调用它的某个方法等)  p1.setXXX(...); 这种情况下就会产生上述错误。 改正方法: 在使用
main" java.lang.NullPointerException 1 解决方法">ionic项目 Exception in thread "main" java.lang.NullPointerException 1 解决方法
Debug ionic项目的时候,报了这么一个错误: TypeError:undefinedisnotafunction 进入输出列表里查看,提示: MSBUILD : cordova-build error :Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerException 1 at org.gradle.wrapper.Gra...
main" java.lang.NullPointerException一例解决">Exception in thread "main" java.lang.NullPointerException一例解决
完整报错信息是: Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerException at scala.io.Source$.fromURL(Source.scala:141) at RunGeoTime$.<em>main</em>(RunGeoTime.scala:66) at RunGeoTime.<em>main</em>(RunGeoTime.scala) at ...
main" java.lang.NullPointerException">Java中使用数组报错:Exception in thread "main" java.lang.NullPointerException
今天在用JAVA写栈的时候报了这样一个错误,出错源码部分如下: private int maxSize; private char[] array= new char[5]; private int top; public Stacks(int size) { this.maxSize = size; top = -1; } public void Push(char...
main" java.lang.NullPointerException">连接数据库连接池 Exception in thread "main" java.lang.NullPointerException
今天测试数据库连接池发现一直是空指针错误。一般都是配置文件出了问题。找了半天才发现,在没有密码的情况下不要加入password=null,估计是没有加入关键字解析的。直接省去不写就好了 driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/igeek2?useUnicode=true&amp;amp;character...
main" java.lang.NullPointerException怎么解决啊">Exception in thread "main" java.lang.NullPointerException怎么解决
[b]StudentMain.java[/b]rnpackage com.lele.jdbc.<em>main</em>;rnrnimport java.util.Scanner;rnrnimport com.lele.jdbc.menu.Menu;rnimport com.lele.jdbc.menu.Menu;rnrnrnpublic class StudentMain rn public static void <em>main</em>(String[] args)rn Scanner s=new Scanner(System.in);rn boolean ok = true;rn while(ok)rn Menu.startInterface();rn int i = s.nextInt(); //输入一个整数rn switch(i )rn case 1:rn Menu.look();rn break;rn case 2:rn Menu.Insert();rn break;rn case 3:rn Menu.alter();rn break;rn case 4:rn Menu.query();rn break;rn case 5:rn System.out.println(" 欢迎使用学生信息管理系统,再见!");rn ok = false;rn break;rn rn rn rn rnrnrnrn[b]Menu.java[/b]rnpackage com.lele.jdbc.menu;rnrnimport java.util.List;rnimport java.util.Scanner;rnrnimport com.lele.jdbc.dao.StudentD;rnimport com.lele.jdbc.model.Student;rnrnpublic class Menu rn rn public static StudentD sD = new StudentD();rn public static Scanner s = new Scanner(System.in);rn rn public static void startInterface()rn System.out.println("***********欢迎使用学生信息管理系统************");rn System.out.println("1.浏览信息数据");rn System.out.println("2.增加信息数据");rn System.out.println("3.修改信息数据");rn System.out.println("4.查询信息数据");rn System.out.println("5.退出");rn rnrn public static void look() rn List< Student > l = sD.getAllStudent();rn System.out.println("所有的学生信息为:");rn System.out.println("-------------------");rn System.out.println("学生编号\t学生学号\t学生姓名\t学生性别\t学生年龄");rn for( Student s : l )rn System.out.println(s.getId()+"\t"+s.getNumber()+"\t"+s.getName()+"\t"+s.getSex()+"\t"+s.getAge());rn rn if( l.size()==0 )rn System.out.println("您所查询的 数据不存在!");rn rn methodEnd();rn rnrn public static void Insert() rn Student student = new Student();rn System.out.println("学生信息输入");rn Scanner s = new Scanner(System.in);rn System.out.println("请输入学生学号:");rn int number= s.nextInt();rn System.out.println("请输入学生姓名:");rn String name=s.next();rn System.out.println("请输入学生性别:");rn String sex=s.next();rn System.out.println("请输入学生年龄:");rn int age=s.nextInt();rn sD.save(student);rn System.out.println("添加成功!");rn methodEnd();rn rnrn public static void alter() rn List< Student > l = sD.getAllStudent();rn System.out.println("全部学生信息:");rn System.out.println("-------------------");rn System.out.println("学生编号\t学生学号\t学生姓名\t学生性别\t学生年龄");rn for( Student s : l )rn System.out.println(s.getId()+"\t"+s.getNumber()+"\t"+s.getName()+"\t"+s.getSex()+"\t"+s.getAge());rn rn Student student = new Student();rn System.out.println("请输入要修改的学生的编号");rn Scanner a=new Scanner(System.in); rn int ID=a.nextInt();rn System.out.println("请输入学生学号:");rn int number= a.nextInt();rn System.out.println("请输入学生姓名:");rn String name=a.next();rn System.out.println("请输入学生性别:");rn String sex=a.next();rn System.out.println("请输入学生年龄:");rn int age=a.nextInt();rn try rn sD.updateById(student);rn catch (Exception e) rn System.out.println("更新失败,请检查您的输入!");rn return ;rn rn System.out.println("更新成功");rn methodEnd();rn rnrn public static void query() rn System.out.println("请输入要查询的学生编号:");rn String num = s.next();rn int number = 0 ;rn try rn number = Integer.parseInt(num);rn catch (NumberFormatException e) rn rn if( number==0 )rn System.out.println("输入的学号不正确,请重新输入:");rn query();rn elsern Student s = sD.getById(number);rn if( s==null )rn System.out.println("所查询的学生不存在!");rn elsern System.out.println(s);rn methodEnd();rn rn rn rn public static void methodEnd()rn System.out.println("请按任意键并回车继续......");rn new Scanner(System.in).next();rn rnrnrnrnrnrnrn[b]DataBase。java[/b]rnrnrnpackage com.lele.jdbc.util;rnrnimport java.sql.Connection;rnimport java.sql.DriverManager;rnimport java.sql.SQLException;rnrnpublic class DataBase rn static rn tryrn Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");rn catch (ClassNotFoundException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn public static Connection getConnection() throws SQLException rn Connection con = null;rn String url = "jdbc:odbc:Driver=MicroSoft Access Driver (*.mdb);DBQ=D:\\study software\\java\\java实验\\综合性实验\\stu.mdb"; rn Connection conn = DriverManager.getConnection(url, "", ""); rn return con;rn rnrnrnrnrnrn[b]StudentD.java[/b]rnpackage com.lele.jdbc.dao;rnrnimport java.sql.Connection;rnimport java.sql.ResultSet;rnimport java.sql.SQLException;rnimport java.sql.Statement;rnimport java.util.ArrayList;rnimport java.util.List;rnrnimport com.lele.jdbc.model.Student;rnimport com.lele.jdbc.util.DataBase;rnrnpublic class StudentD rnrn private Connection con = null;rn private Statement stmt = null;rn private ResultSet rs = null;rn rn public List getAllStudent() rn List list = new ArrayList();rn try rn con = DataBase.getConnection();rn stmt = con.createStatement();rn String sql = "select * from student";rn rs = stmt.executeQuery(sql);rn while(rs.next()) rn Student po = new Student();rn po.setId(rs.getInt(1));rn po.setNumber(rs.getInt(2));rn po.setName(rs.getString(3));rn po.setSex(rs.getString(4));rn po.setAge(rs.getInt(5));rn list.add(po);rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn finally rn try rn rs.close();rn stmt.close();rn con.close();rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn return list;rn rn public boolean save(Student po) rn System.out.println(po);rn boolean b =false;rn try rn con = DataBase.getConnection();rn stmt = con.createStatement();rn String sql = "insert into student values(null,"+po.getNumber()+",'"+po.getName()+"','"+po.getSex()+"',"+po.getAge()+")";rn int i =stmt.executeUpdate(sql);rn if(i>0) b = true;rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn finally rn try rn stmt.close();rn con.close();rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn return b;rn rn rn public Student getById(int id) rn Student po = null;rn try rn con = DataBase.getConnection();rn stmt = con.createStatement();rn String sql = "select * from student where Id="+id;rn rs = stmt.executeQuery(sql);rn if(rs.next()) rn po = new Student();rn po.setId(rs.getInt(1));rn po.setNumber(rs.getInt(2));rn po.setName(rs.getString(3));rn po.setSex(rs.getString(4));rn po.setAge(rs.getInt(5));rn rn rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn finally rn try rn stmt.close();rn con.close();rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn return po;rn rn public boolean updateById(Student po) rn boolean b =false;rn try rn con = DataBase.getConnection();rn stmt = con.createStatement();rn String sql = "update student set name='"+po.getName()+"',age="+po.getAge()+",gender='"+po.getSex()+"',studyNumber='"+po.getNumber()rn +"' where Id="+po.getId();rn int i = stmt.executeUpdate(sql);rn if(i>0) b = true;rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn finally rn try rn stmt.close();rn con.close();rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn return b;rn rnrnrnrnrnrnrn[b]rnStudent.java[/b]rnrnrnpackage com.lele.jdbc.model;rnrnpublic class Student rn rn /**rn * 学生编号rn */rn private int id;rn /**rn * 学好rn */rn private int number;rn /**rn * 姓名rn */rn private String name;rn /**rn * 性别rn */rn private String sex;rn /**rn * 年龄rn */rn private int age;rn rn rn rn rn public int getId() rn return id;rn rn public void setId(int id) rn this.id = id;rn rn public int getNumber() rn return number;rn rn public void setNumber(int Number) rn this.number = Number;rn rn public String getName() rn return name;rn rn public void setName(String name) rn this.name = name;rn rn public String getSex() rn return sex;rn rn public void setSex(String sex) rn this.sex = sex;rn rn public int getAge() rn return age;rn rn public void setAge(int age) rn this.age = age;rn rn @Overridern public String toString() rn return "学生 [编号=" + id + ", 学号=" + number + ", 名字="rn + name + ", 性别=" + sex + ", 年龄=" + age + "]";rn rn rn rnrnrnrnrnrn一下是异常提示rnrnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at com.lele.jdbc.dao.StudentD.getAllStudent(StudentD.java:40)rn at com.lele.jdbc.menu.Menu.look(Menu.java:24)rn at com.lele.jdbc.<em>main</em>.StudentMain.<em>main</em>(StudentMain.java:18)
main" java.lang.NullPointerException 怎么解决。">异常Exception in thread "main" java.lang.NullPointerException 怎么解决
我写了一个两个机器通信的程序,这个服务器端的代码rn[code=Java]rnpackage mySocket;rnrn//服务器端程序rnimport java.io.*;rnimport java.net.*;rnimport java.awt.*;rnimport java.awt.event.*;rnrnpublic class Server1 extends Frame implements ActionListener rn Label label = new Label("输入信息");rn TextField tf = new TextField(20);rn TextArea ta = new TextArea();rn Panel panel = new Panel();// 创建面板对象rn ServerSocket server;rn Socket Client;rn InputStream DataIn;rn OutputStream DataOut;rnrn @SuppressWarnings("deprecation")rn public Server1() rn super("通信--服务器端");rn setSize(300, 180);rn panel.add(label);// 在面板上添加标签rn panel.add(tf);// 在面板上添加文本框rn tf.addActionListener(this);// 注册rn add("North", panel);// 在窗体上添加面板rn add("Center", ta);// 在窗体上添加文本区rn addWindowListener(new WindowAdapter() rn public void windowClosing(WindowEvent e) rn System.exit(0);rn rn );rn show();rn try rn server = new ServerSocket(8888);rn Client = server.accept();rn ta.append("已经和客户端建立连接:" + Client.getInetAddress().getHostName()rn + "\n\n");rn DataIn = Client.getInputStream();rn DataOut = Client.getOutputStream();rn catch (IOException ioe) rn rn while (true) rn try rn byte buff[] = new byte[512];// 缓冲数组rn DataIn.read(buff);rn String str = new String(buff);// 接受客户端发送的数据包rn ta.append("Client :" + str + "\n");rn ta.append("\n");rn catch (IOException ioe) rn rn rn rnrn public static void <em>main</em>(String args[]) rn new Server1();rn rnrn public void actionPerformed(ActionEvent e)// 事件处理程序rn rn try rn String str = new String(tf.getText());rn byte buf[] = str.getBytes();rn tf.setText(" ");rn DataOut.write(buf);rn ta.append("Server :" + str + "\n");rn catch (IOException ioe) rn rn rnrnrn[/code]rn运行有rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at mySocket.Server1.(Server1.java:46)rn at mySocket.Server1.<em>main</em>(Server1.java:56)rn这样的异常rn界面还是能出来的。rn初学java,大家帮忙看看。rn谢谢各位了。
main" java.lang.NullPointerException错误怎么解决">Exception in thread "main" java.lang.NullPointerException错误怎么解决
下面这段程序,编译没问题,但运行时候会报错rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at operation.GetFileInfo.getFileNum(GetFileInfo.java:20)rn at operation.ExtractOperation.extraction(ExtractOperation.java:11)rn at operation.ExtractOperation.<em>main</em>(ExtractOperation.java:30)rn报错定位在下面红色的语句上,我知道这是说有空指针存在,可是我找不到。rn麻烦大家帮我找找错误!!rnrn此外,我的程序是从html源代码中匹配文字,然后输入到文件parameter.txt中,有一次运行成功了,建立了txt文件,却没内容,麻烦大家帮个忙!谢谢!rnrn[code=Java]rnpublic class ExtractOperation rn static String filePath = "./source/";rn public void extraction(String filePath) throws IOExceptionrn GetFileInfo gfn = new GetFileInfo();rn filePath=filePath+gfn.getFileName(filePath)+"/";rn [color=#FF0000]long num = gfn.getFileNum(filePath); [/color] for(int i=1;i;//匹配参数名称 rn Pattern p1=Pattern.compile(s1);rn Matcher m1=p1.matcher(str);rn while(m1.find())rn rn String s=m1.group(); rn bw.write(s);rn rn bw.close(); rn rnrn[/code]rn
main" java.lang.NullPointerException怎么解决">Exception in thread "main" java.lang.NullPointerException怎么解决
以下是我写的一个简单的程序,编译时没问题,运行时却抛出异常rnimport java.util.Scanner;rnpublic class Coursernrnrn /**rn * @param argsrn */rn public String course;rn public String[] student = new String[100];rn public int count;rn public void getcourse()rn rn Scanner keyboard = new Scanner(System.in);rn System.out.println("输入课程名称");rn course=keyboard.nextLine();rn rn public void getstudent()rn rn Scanner keyboard = new Scanner(System.in);rn System.out.println("输入选修课程"+course+"的学生姓名,输入1结束");rn boolean flat=true; rn while(flat)rn rn int i=0;rn count=0;rn student[i]=new String();rn student[i++]=keyboard.nextLine();rn count++;rn if(student[i].equals("1"))rn flat=false;rn rn rn public void print()rn rn for(int i=0;i
main" java.lang.NullPointerException">出现Exception in thread "main" java.lang.NullPointerException
import java.io.Console;rnpublic class ConsoleDemo rnpublic static void <em>main</em> (String[] args) rnSystem.out.print("请输入名称: ");rnConsole console = System.console();rnString name = console.readLine();rnSystem.out.println("你输入的名称..." + name);rnrnrn/** Creates a new instance of ConsoleDemo */rnpublic ConsoleDemo() rnrnrnrnrn直接在命令行编译运行通过,jdk6环境rn在netbeans5.5中编译通过,运行出现错误,请大家帮忙看看rn错误提示如下 :rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrnat ConsoleDemo.<em>main</em>(ConsoleDemo.java:19)rn请输入名称:
main" java.lang.NullPointerException">求解:Exception in thread "main" java.lang.NullPointerException
直接上代码哈。视频里的例子,我编译通过了,但是运行就报这个错误,我找不到错误在哪儿啊。rnpackage zicheng;rnrnpublic class Josephu rnrn public static void <em>main</em>(String[] args)rn rn rn CycLink cyclink = new CycLink();rn cyclink.setLen(8);rn cyclink.creatLink();rn cyclink.setk(2);rn cyclink.setm(2);rn rn //cyclink.show();rn cyclink.play();rnrn rnrnrnclass Childrn int no;rn Child nextChild = null;rn public Child(int no)rn rn //给一个编号rn this.no=no;rn rn rnrn class CycLinkrnrn //先定义一个指向链表第一个小孩的引用rn Child firstchild = null;rn Child temp =null;rn int len = 0; //共有几个小孩rn int k=0;rn int m=0;rn rn //设置链表的大小rn public void setLen(int len)rn rn this.len = len;rn rn public void setk(int k)rn rn this.k=k;rn rn public void setm(int m)rn rn this.m=m;rn rn rn public void play()rn rn //1.知道开始数数的人rn for(int i=1;i
main" java.lang.NullPointerException">运行时Exception in thread "main" java.lang.NullPointerException
这是我的源代码~不知道哪里错了~请教~谢谢rnimport java.io.*;rnpublic class Gradernrn public static void <em>main</em>(String args[])rn rn int num,average,num1,num2;rn char ch;rn FileInputStream fin;rn DataInputStream din=null;rn tryrn while ((ch=din.readChar())!='\n')rn rn fin=new FileInputStream("d:\\test\\1.txt");rn din=new DataInputStream(fin);rn ch=din.readChar();rn num1=din.readInt();rn num2=din.readInt();rn num=num1+num2;rn average=((num1+num2)/2);rn System.out.println(ch+num+average);rn rn System.out.println("输出完毕");rn rn catch (Exception e)rn rn System.out.println("Error!");rn rn rn rnrnrn运行出现Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerException
main" java.lang.NullPointerException">请教:Exception in thread "main" java.lang.NullPointerException
运行内容如下的UseDriver.java文件,rnrnrnimport java.sql.*;rnpublic class UseDriver rn public static void <em>main</em>(String[] args) rn String url = "jdbc:mysql://localhost/sql_test";rn String userName = "root";rn String password = " ";rn String sql = null;rn Connection conn = null;rn Statement stmt = null;rn try rn //第一步:加载驱动器rn Class.forName("com.mysql.jdbc.Driver");rn catch(ClassNotFoundException e) rn System.err.print("ClassNotFoundException");rn rn rn try rn //第二步:调用DriverManager.getConnection静态方法得到数据库连接rn conn = DriverManager.getConnection(url, userName, password);rn //创建Statement语句rn stmt = conn.createStatement();rn sql = "INSERT INTO student " +rn "VALUES('12', 'zhangjun', 'tianjin', '1981-01-01')";rn //使用Statement语句对象执行SQL语句rn stmt.executeUpdate("DELETE FROM student WHERE stu_id='12'");rn stmt.executeUpdate(sql);rn System.out.println("Insert a row successful!");rn catch(SQLException e) rn System.err.println("Insert SQLException");rn finally rn //关闭语句和数据库连接rn try rn stmt.close();rn conn.close();rn catch(SQLException e) rn System.err.println("Close SQLException");rn rn rn rn rnrnrnrnrn在DOS窗体下运行,不知<em>怎么</em>出现如下的错误,请问一下这可能是什么错误啊,谢谢!rnrnrnG:\>javac UseDriver.javarnrnG:\>java UseDriverrnInsert SQLExceptionrnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at UseDriver.<em>main</em>(UseDriver.java:35)rn
main" java.lang.NullPointerException">报错:Exception in thread "main" java.lang.NullPointerException
报错:Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrnrnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at org.shp.dao.InputData.getInt([color=#FF0000]InputData.java:20)[/color]rn at org.shp.dao.Menu.showMain(Menu.java:23)rn at org.shp.dao.Menu.(Menu.java:12)rn at org.shp.dao.Main.<em>main</em>(Main.java:5)rn我的InputData 中的第20 行是:rnrnif(!(str.matches("\\[d]"))) // 是对输入字符的校验,rnrn不知道是什么地方错了呀,各位大哥帮忙看看。。rnrn还有就是:Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerException 是什么地方错了呀。。。
main" java.lang.NullPointerException">求助:Exception in thread "main" java.lang.NullPointerException
import java.io.*;rnpublic class DirFilern static String fileResult[];rn public static void printDirect(File root)rn File myFile = new File(root,"123.txt");rn if (myFile.exists())rn System.out.println(root);rn if(fileResult==null)rn//就是下面这一句出错!rn fileResult[0] = root.getPath();rn rn elsern fileResult[fileResult.length] = root.getPath();rn rn File subroots[]=root.listFiles(new FileFilter()rn public boolean accept(File pathname) rn return pathname.isDirectory();rn rn );rn if(subroots!=null)rn for(int i=0;i
main" java.lang.NullPointerException">如何解决:Exception in thread "main" java.lang.NullPointerException
import java.util.*; rnimport javax.swing.*;rnimport java.awt.*;rnimport java.awt.event.*;rnimport javax.swing.JFrame.*;rnrnclass win extends JFramernString data[][]="file","edit","view","help","new","open","save","copy","paste","font","find";rnJMenuBar bar=new JMenuBar();rnJMenu menu[];rnJMenuItem item[][];rnrnwin()rnsetBounds(500,500,500,500);rnfor(int i=0;i
main" java.lang.NullPointerException">错误信息 Exception in thread "main" java.lang.NullPointerException
今天复习了以下hibernate 尽然出现Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerException at com.java.move.test.save(test.java:28)rn at com.java.move.test.<em>main</em>(test.java:10)rn错误rn废话不多说请观代码rn-------------------------------------------------------------------------------------------------------------------------------------------------------rn[code=java]package com.java.move;rnrnimport org.hibernate.Session;rnimport org.hibernate.Transaction;rnrnimport com.pb.hibernate.util.HibernateSessionFactory;rnrnpublic class test rn public static void <em>main</em>(String args[])rn save();rn rn public static void save()rn Grade g = new Grade();rn g.setGid(110701);rn g.setGname("计应一班");rn g.setGdesc("计算机应用一班");rn rn Student stu1 = new Student();rn stu1.setSid(11070101);rn stu1.setSname("大姑爷");rn stu1.setSex("男");rn rn Student stu2 = new Student();rn stu2.setSid(11070102);rn stu2.setSname("老婆婆");rn stu2.setSex("女");rn rn Session session = HibernateSessionFactory.getSessionFactory().openSession();rn Transaction tr = session.beginTransaction();rn session.save(g);rn session.save(stu1);rn session.save(stu2);rn tr.commit();rn session.close();rn rnrn[/code]rn如何?
main" java.lang.NullPointerException">如何解决Exception in thread "main" java.lang.NullPointerException
import java.awt.*;rnimport java.awt.event.ActionEvent;rnimport java.awt.event.ActionListener;rnimport java.awt.event.*;rnpublic class awt rn public static void <em>main</em>(String[] args)rn new frame1("aaa");rn // fa.Init();rn // fa.rigisteraction();rn rnrnclass frame1 extends Framern public frame1(String title)rn super(title);rn // this.setTitle(title);rn Init();rn rigisteraction();rn rn rn private FlowLayout flowlout=null;rn private CardLayout card_lout=null;rn private Panel flowpanel=null;rn private Panel cardpanel=null;rn private Button button1=null;rn private Button button2=null;rn private Button button3=null;rn private Button button4=null;rn private Label label1=null;rn private Label label2=null;rn private Label label3=null;rn private Label label4=null;rn private TextField label5=null;rn rn public void Init()rn card_lout=new CardLayout();rn flowlout=new FlowLayout(FlowLayout.LEFT,20,20);rn cardpanel=new Panel();rn flowpanel=new Panel();rn Button button1=new Button("first");rn Button button2=new Button("next");rn Button button3=new Button("previous");rn Button button4=new Button("final");rn label1=new Label("first picture",Label.CENTER);rn label2=new Label("two picture",Label.CENTER);rn label3=new Label("three picture",Label.CENTER);rn label4=new Label("four picture",Label.CENTER);rn TextField label5=new TextField();rn cardpanel.setBackground(Color.red);rn flowpanel.add(button1);rn flowpanel.add(button2);rn flowpanel.add(button3);rn flowpanel.add(button4);rn flowpanel.setLayout(flowlout);rn cardpanel.setLayout(card_lout);rn cardpanel.add(label1);rn cardpanel.add(label2);rn cardpanel.add(label3);rn cardpanel.add(label4);rn cardpanel.add(label5);rn this.add( flowpanel,BorderLayout.SOUTH);rn this.add( cardpanel,BorderLayout.CENTER);rn this.setVisible(true);rn flowpanel.add(button1);rn this.setBounds(100,100,300,300);rn this.setBackground(Color.yellow);rn rn rn public void rigisteraction()rn liaction act=new liaction();rn//给4个按钮注册监听同一个事件监听器rn button1.addActionListener(act);rn button2.addActionListener(act);rn button3.addActionListener(act);rn button4.addActionListener(act);rn rn rn rn class liaction implements ActionListenerrn rnrn @Overridern public void actionPerformed(ActionEvent e) rn // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.rn /* System.out.println(e.getActionCommand());rn System.out.println(e.getSource());*/rn Object obj=e.getSource();rn if(obj==button1)rn card_lout.first(cardpanel);rn else if(obj==button2)rn card_lout.next(cardpanel);rn else if(obj==button3)rn card_lout.previous(cardpanel);rn elsern card_lout.last(cardpanel);rn rn rn rnrn这个程序想测试一个事件监听器的功能,当按下一个键,然后图片翻页。rn编译的时候没有错误,运行时有显示界面,但又弹出错误Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at zhizhuobiao2.frame1.rigisteraction(awt.java:100) button1.addActionListener(act);rn at zhizhuobiao2.frame1.(awt.java:47) rigisteraction();rn at zhizhuobiao2.awt.<em>main</em>(awt.java:37) new frame1("aaa");
main" java.lang.NullPointerException怎么解决">我的程序中Exception in thread "main" java.lang.NullPointerException怎么解决
以下是我写的一个简单的程序,编译时没问题,运行时却抛出异常rn Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at home1.(home1.java:16)rn at home1.<em>main</em>(home1.java:41)rnrn这是我的程序rnimport java.awt.*;rn//import java.awt.event.*;rnimport javax.swing.*;rnpublic class home1 extends JFramernprivate JButton buttons[],submit;rn private JLabel labels[];rn private JTextField fields[];rn private String[] strb="开始交易","保存记录","修改记录","停止交易";rn private String[] strl="账号","商品","价格","现金支付";rn public home1()rn rn JPanel arraybutton=new JPanel(new GridLayout(1,4));rn rn for(int count=0;count);rn inputtable.add(submit,15);rn rn rn Container container=getContentPane();rn container.setLayout(new BorderLayout(5,5));rn container.add(arraybutton,BorderLayout.NORTH);rn container.add(inputtable,BorderLayout.CENTER);rn setSize(500,500);rn setVisible(true);rnrn rn public static void <em>main</em>(String[] args)rn rn rn home1 application=new home1();rn application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn rnrn rnrnrnrn麻烦高手指教
main" java.lang.NullPointerException">提示错误Exception in thread "main" java.lang.NullPointerException
<em>main</em>文件rnpublic class MMain rn public static void <em>main</em>(String[] args)rn rn //tryrn Mankey[] mk=new Mankey[100];rn Mankey.Inroad(mk);rn System.out.println(Mankey.clean(mk)); rn //catch(Exception Ex);rn rn rnrnMankey文件rnpublic class Mankey rn public int num,prior,next;rn public Mankey()rn rn rn rn static void Inroad(Mankey[] m)rn rn int last=m.length;rn for (int i=0;i
main" java.lang.NullPointerException at company.insertAe">请教:Exception in thread "main" java.lang.NullPointerException at company.insertAe
[code=Java]rnrnpublic class company rn rn static employee intArray[] = null;rn static int i = 0;rn rn static void insertAemployee(employee A) rn intArray[i] = A;rn i ++;rn rn rn void deleteAemployee(String name)rn for(int m = 0;m < i; m ++)rn while(intArray[m].name == name)rn intArray[m] = null;rn rn rn rn rn void showPay(String name)rn double salary = 0;rn for(int m = 0;m < i; m ++)rn while(intArray[m].name == name)rn salary = intArray[m].countPay(intArray[m]);rn rn rn rn System.out.println("员工" + name + "的工资为:" + salary);rn rn rn rn static void showAllpay(company A)rn double allSalary = 0;rn for(int m = 0;m < i; m ++)rn allSalary = allSalary + intArray[m].countPay(intArray[m]);rn rn System.out.println("所有员工的工资和为:" + allSalary);rn rn rn rnpublic static void <em>main</em>(String[] args) rn rn company company1 = new company(); rn employee hourEmployee1 = new hourEmployee(200,10);rn employee hourEmployee2 = new hourEmployee(230,10); rn employee sellEmployee1 = new sellEmployee(5000);rn employee sellEmployee2 = new sellEmployee(200000);rn employee commonEmployee1 = new commonEmployee(205);rnrn rn insertAemployee(hourEmployee1);rn insertAemployee(hourEmployee2);rn insertAemployee(sellEmployee1);rn insertAemployee(sellEmployee2);rn insertAemployee(commonEmployee1);rn showAllpay(company1);rn rn rn employee headgearEmployee1 = new headgearEmployee(30);rn insertAemployee(headgearEmployee1);rn showAllpay(company1);rn rn rnrnrnrnrnrn[/code]
main" java.lang.NullPointerException at Server.main(Server.java:22)">Exception in thread "main" java.lang.NullPointerException at Server.main(Server.java:22)
详见代码,结果如下:rn正在监听Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at Server.<em>main</em>(Server.java:22)rnrn[code=Java]rnimport java.io.*;rnimport java.net.*;rnimport java.util.*;rnimport java.awt.*;rnpublic class Serverrn rn public static void <em>main</em>(String args[])rn rn ServerSocket server=null;rn ServerThread <em>thread</em>;rn Socket you=null;rn while(true) rn rn try rn server=new ServerSocket(4331);//创建在端口4331上负责监听的 ServerSocket对象。rn rn catch(IOException e1) rn rn System.out.println("正在监听"); rn rn try rn you=server.accept();// server返回和客户端相连接的Socket对象。rn System.out.println("客户的地址:"+you.getInetAddress());rn rn rn catch (IOException e)rn rn System.out.println("正在等待客户");rn rn if(you!=null) rn rn new ServerThread(you).start(); //为每个客户启动一个专门的线程。 rn rn else rn rn continue;rn rn rn rnrnclass ServerThread extends Threadrn rn Socket socket;rn ObjectInputStream in=null; rn ObjectOutputStream out=null;rn String s=null;rn ServerThread(Socket t)rn rn socket=t;rn try rn out=new ObjectOutputStream(socket.getOutputStream()); //socket返回输出流。rn in=new ObjectInputStream(socket.getInputStream()); //socket返回输入流。rn rn catch (IOException e)rn rn rn public void run() rn rn TextArea text=new TextArea("你好,我是服务器",12,12);rn tryrn rn out.writeBytes(text.getText());rn out.flush();rn //out写对象text到客户端。rn rn catch (IOException e) rn rn System.out.println("客户离开");rn rn rnrn[/code]rnrn另外,附上客户端代码:rn[code=Java]rnimport java.net.*;rnimport java.io.*;rnimport java.awt.*;rnimport java.awt.event.*;rnclass Client extends Frame implements Runnable,ActionListenerrn rn Button connection;rn Socket socket=null;rn ObjectInputStream in=null; rn ObjectOutputStream out=null;rn Thread <em>thread</em>; rn public Client()rn rn socket=new Socket(); rn connection=new Button("连接服务器,读取文本区对象");rn add(connection,BorderLayout.NORTH);rn connection.addActionListener(this);rn <em>thread</em> = new Thread(this);rn setBounds(100,100,360,310);rn setVisible(true);rn addWindowListener(new WindowAdapter()rn rn public void windowClosing(WindowEvent e)rn rn System.exit(0);rn rn rn );rn rn public void run()rn rn while(true)rn rn try rn TextArea text=(TextArea)in.readObject(); rn add(text,BorderLayout.CENTER);rn validate();rn rn catch(Exception e) rn rn break;rn rn rn rn public void actionPerformed(ActionEvent e)rn rn if(e.getSource()==connection)rn rn tryrn rn if(socket.isConnected())rn rn rn rn elsern rn InetAddress address=InetAddress.getByName("127.0.0.1");rn InetSocketAddress socketAddress=new InetSocketAddress(address,4331);//创建端口为4331、地址为rn //address的socketAddressrn socket.connect(socketAddress) ;//socket建立和socketAddress的连接呼叫。rn in =new ObjectInputStream(socket.getInputStream()); //socket返回输入流。rn out = new ObjectOutputStream(socket.getOutputStream()); //socket返回输出流。rn <em>thread</em>.start();rn rn rn catch (Exception ee)rn rn rn public static void <em>main</em>(String args[])rn rn Client win=new Client();rn rnrn[/code]
main" java.lang.NullPointerException">JAVA小问题:Exception in thread "main" java.lang.NullPointerException
import java.awt.*;rnimport java.awt.event.*;rnrnclass testItemEvent extends WindowAdapter implements ItemListener,ActionListenerrnrn Frame f=new Frame("选择性组件应用");rn Label l1,l2,l3,l4;rn Panel p1,p2;rn Checkbox cb1,cb2,cb3,cb4,ocb1,ocb2,ocb3,ocb4;rn Button submitB;rn boolean ans1=false,ans2=false;rn void setMulCheckbox(Frame f)rn rn l1=new Label("多项选择题,下面哪些国家是文明古国?");rn l1.setForeground(Color.red);rn l2=new Label("结果:");l2.setForeground(Color.blue);rn p1=new Panel();p1.setLayout(new GridLayout(3,1));rn Panel p=new Panel();rn cb1=new Checkbox("中国"); cb2=new Checkbox("希娜");rn cb3=new Checkbox("印度");cb4=new Checkbox("罗马");rn p1.add(l1); p.add(cb1); p.add(cb2);rn p.add(cb3); p.add(cb4); p1.add(p); p1.add(l2);rn cb1.addItemListener(this); cb2.addItemListener(this);rn cb3.addItemListener(this); cb4.addItemListener(this);rn f.add(p1);rn rn void SetOnlyCheckbox(Frame f)rn rn l3=new Label("单项选择:下面哪个国家不是四大文明古国?");rn l3.setForeground(Color.red);rn l4=new Label("结果:"); l4.setForeground(Color.blue);rn p2=new Panel(); p2.setLayout(new GridLayout(3,1));rn Panel p=new Panel();rn CheckboxGroup cg=new CheckboxGroup();rn ocb1=new Checkbox("中国",cg,true); ocb2=new Checkbox("埃及",cg,false);rn ocb1=new Checkbox("印度",cg,false); ocb4=new Checkbox("罗马",cg,false);rn p2.add(l3);rn p.add(ocb1); p.add(ocb2); p.add(ocb3);rn p.add(ocb4); p2.add(p); p2.add(l4);rn ocb1.addItemListener(this); ocb2.addItemListener(this);rn ocb3.addItemListener(this); ocb4.addItemListener(this);rn f.add(p2);rn rn public void display()rn rn f.setLayout(new GridLayout(3,1));rn f.setLocation(200,140);rn setMulCheckbox(f);rn SetOnlyCheckbox(f);rn submitB=new Button("提交答案");rn submitB.addActionListener(this);rn Panel p=new Panel(); p.add(submitB);rn f.add(p); f.addWindowListener(this);rn f.setVisible(true);rn rn public void WindowClosing(WindowEvent e)rn rn System.exit(0);rn rn public void actionPerformed(ActionEvent e)rn rn if(e.getSource()==submitB)rn rn if(ans1)rn l2.setText("完全正确!加10分");rn else rn l2.setText("继续加油额!");rn if(ans2)rn l4.setText("完全正确!加10分");rn elsern l4.setText("继续加油额!");rn rn rn public void itemStateChanged(ItemEvent e)rn rn Checkbox c=(Checkbox)e.getSource();rn if((c==cb1)||(c==cb2)||(c==cb3)||(c==cb4))rn if((cb1.getState()&&cb3.getState())&&!(cb2.getState()||cb4.getState()))rn ans1=true;rn elsern ans1=false;rn if((c==cb1)||(c==cb2)||(c==cb3)||(c==cb4))rn if(ocb4.getState()&&!(ocb1.getState()||ocb2.getState()||ocb3.getState()))rn ans2=true;rn else ans2=false;rn rnrnpublic class Testrnrn public static void <em>main</em>(String[] args) rn rn (new testItemEvent()).display();rn rnrn求指教,百度了说什么未初始化,我看半天,都初始化了!
main" java.lang.NullPointerException">java程序抛出异常 Exception in thread "main" java.lang.NullPointerException
程序的全部代码如下:rnrnimport java.awt.*;rnimport java.awt.event.*;rnimport java.net.*;rnrnimport javax.swing.*;rnrnpublic class JButtonTest extends JFrame rn /**rn * rn */rn private static final long serialVersionUID = 1L;rnrn public JButtonTest() rn URL url = JButtonTest.class.getResource("/imageButtoo.jpg");rn Icon icon = new ImageIcon(url);rn setLayout(new GridLayout(3, 2, 5, 5)); // 设置网格布局管理器rn Container c = getContentPane(); // 创建容器rn for (int i = 0; i < 5; i++) rn // 创建按钮,同时设置按钮文字与图标rn JButton J = new JButton("button" + i, icon);rn c.add(J); // 在容器中添加按钮rn if (i % 2 == 0) rn J.setEnabled(false); // 设置其中一些按钮不可用rn rn rn JButton jb = new JButton(); // 实例化一个没有文字与图片的按钮rn jb.setMaximumSize(new Dimension(90, 30)); // 设置按钮与图片相同大小rn jb.setIcon(icon); // 为按钮设置图标rn jb.setHideActionText(true);rn jb.setToolTipText("图片按钮"); // 设置按钮提示为文字rn jb.setBorderPainted(false); // 设置按钮边界不显示rn jb.addActionListener(new ActionListener() // 为按钮添加监听事件rn public void actionPerformed(ActionEvent e) rn // 弹出确认对话框rn JOptionPane.showMessageDialog(null, "弹出对话框");rn rn );rn c.add(jb); // 将按钮添加到容器中rn rn setTitle("创建带文字与图片的按钮");rn setSize(350, 150);rn setVisible(true);rn setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);rn rn rn public static void <em>main</em>(String args[]) rn new JButtonTest();rn rnrnrnrnrn抛出的异常如下:rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at javax.swing.ImageIcon.(Unknown Source)rn at Thirteen.JButtonTest.(JButtonTest.java:17)rn at Thirteen.JButtonTest.<em>main</em>(JButtonTest.java:49)rn第17行也就是:Icon icon = new ImageIcon(url);这一行rn第49行也就是:new JButtonTest();这一行rn显示的是这两行抛出异常,请问到底是什么问题,要如何修改才能正常运行程序?rn
main" java.lang.NullPointerException">新人问题。Exception in thread "main" java.lang.NullPointerException
最近开始学习java, 做作业遇到理解不了的问题,请教一下。rn-----------------------------------------rnpublic class Assign3 rnrn public static void <em>main</em>(String[] args) rn // TODO Auto-generated method stubrn CodeBreaker a3 = new CodeBreaker();rn a3.display();rnrn // end of methodrn // end if classrnrn-----------------------------------rnpublic class CodeBreaker rn private CodeLetter letter1;rn private CodeLetter letter2;rn private CodeLetter letter3;rn rn public CodeBreaker()rn CodeLetter letter1 = new CodeLetter();rn CodeLetter letter2 = new CodeLetter();rn CodeLetter letter3 = new CodeLetter();rn letter1.display();rn letter2.display();rn letter3.display();rn System.out.println(); rn rnrn public void display()rn System.out.print("The code was "); rn letter1.display();rn letter2.display();rn letter3.display();rn rn rn// end of classrnrn-----------------------rnimport java.util.Random;rnrnpublic class CodeLetter rn private char letterValue;rn Random rnd = new Random();rn rn public CodeLetter()rn letterValue = (char) (rnd.nextInt(5)+'A');rn rn rn public void display()rn System.out.print(letterValue);rn rnrnrn---------------------------rn运行结果:rnDCBrnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at CodeBreaker.checkGuess(CodeBreaker.java:18)rn at Assign3.<em>main</em>(Assign3.java:6)rnrn我的问题是,为什么在public class CodeBreaker里,同样是调用public class CodeLetter的public void display(),在public CodeBreaker()可以打印字母(DCB),但是在public void display()却出错,不能打印了呢?
main" java.lang.NullPointerException">What's wrong ---Exception in thread "main" java.lang.NullPointerException
Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at java.awt.Container.addImpl(Container.java:341)rn at java.awt.Container.add(Container.java:267)rn at Frame1.(Frame1.java:59)rn at Frame1.<em>main</em>(Frame1.java:69)rn请问这是什么错?
main" java.lang.NullPointerException">初学者遇到问题~Exception in thread "main" java.lang.NullPointerException
各位大虾,帮帮忙,小女子初学java,就遇到想不明白的问题了:(rnimport java.awt.*;rnimport java.awt.event.ActionEvent;rnimport java.awt.event.ActionListener;rnrnimport javax.swing.JButton;rnimport javax.swing.JFrame;rnimport javax.swing.JLabel;rnrnpublic class QRFrame extends JFramernrnrn QRFrame frame; rn public QRFrame()rn rn super("hello");rn Container cp=frame.getContentPane();rn JLabel labName=new JLabel("name"); rn cp.setLayout(new BorderLayout());rn cp.add(labName,BorderLayout.NORTH);rn rn rn rn public static void <em>main</em>(String[] args) rn rn JFrame frame=new QRFrame();rn frame.setSize(600,800);rn frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn frame.setVisible(true); rn rnrnrn错误如下:Exception in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at com.songlyric.QRFrame.(QRFrame.java:21)rn at com.songlyric.QRFrame.<em>main</em>(QRFrame.java:34)rn不明白,呜呜~
main" java.lang.NullPointerException错误求解">关于Exception in thread "main" java.lang.NullPointerException错误求解
package fddffd;rnrnclass Customerrnrnprivate int personcode,type,money;rnCustomer()rnCustomer(int t1,int t2,int t3)rnrnpersoncode=t1;rntype=t2;rnmoney=t3;rnrnpublic int getcode()rnrnreturn personcode;rnrnpublic int gettype()rnrnreturn type;rnrnpublic int getmoney()rnrnreturn money;rnrnrnclass QueuernrnCustomer p[];rnint size=0;rnQueue()rnrnint i;rnfor(i=0;i<100;i++)rnrnp[i]=new Customer();rnrnrnpublic void add(Customer c)rnrnp[size]=c;rnsize++;rnrnpublic void delete()rnrnint i;rnfor(i=0;iamount)rnrnCustomer c2;rnc2=q1.gettop();rnq1.delete();rnq2.add(c2);rnreturn 0;rnrnelsernrnamount=amount-q1.p[0].getmoney();rndisplay(q1);rnorder++;rnq1.delete();rnreturn 0;rnrnrnelsernrnamount=amount+q1.p[0].getmoney();rndisplay(q1);rnq1.delete();rnreturn 1;rnrnrnpublic void dealq2()rnrnif(q2.p[0].getmoney()(Test.java:35)rnat fddffd.Bank.(Test.java:69)rnat fddffd.Test.<em>main</em>(Test.java:144)
main" java.lang.NullPointerException……………………在线等。。。。。。。">Exception in thread "main" java.lang.NullPointerException……………………在线等。。。。。。。
写了一个关于链表的简单程序,出现RT的异常,高手指点一下。先谢了。代码如下:rn[code=Java]class Personrn public String name;rn public void setname(String b)rn name=b;rn rn String getname()rn return name;rn rnrnclass Node rn public Person person;rn public Node head;rn public Node next;rn public boolean isEmpty()rn return head==null;rn //判断链表是否为空rn public void printAll()rn Node tmp=head;rn if(isEmpty())rn System.out.println("这是一个空链表");rn while(tmp!=null)rn System.out.print(tmp.person.getname()+" ");rn tmp=tmp.next;rn rn //遍历链表打印结果rn rnrnrnpublic class LianBiao rn public static void <em>main</em>(String [] args)rn Node nod=new Node();rn nod.person.setname("qq");rn nod.next=new Node();rn nod.head=nod;rn Node tem=new Node();rn tem=nod.next;rn tem.person.setname("qw");rn nod.printAll();rn rn[/code]
main" java.lang.NullPointerException at A.main(A.java:8)">Exception in thread "main" java.lang.NullPointerException at A.main(A.java:8)
public class A rn rn B b1; rn B b2=new B(); rn public static void <em>main</em>(String args[]) rn rn A a1=new A(); rn System.out.println(a1.b1.x); //这一行出错了rn System.out.println(a1.b2.x);rn rn rnrnclass B rn rn int x=10; rn rnrn请问对象作为成员必须要new一个空间吗?为什么会出现这样的错误。
main" java.lang.NullPointerException">请教一个问题:Exception in thread "main" java.lang.NullPointerException
错误提示:rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at awt.GridLayoutTest.init(GridLayoutTest.java:40)rn at awt.GridLayoutTest.(GridLayoutTest.java:28)rn at awt.GridLayoutTest.<em>main</em>(GridLayoutTest.java:70)rn程序如下:rnpackage awt;rnrnimport java.awt.Button;rnimport java.awt.Color;rnimport java.awt.Frame;rnimport java.awt.GridLayout;rnimport java.awt.Panel;rnimport java.awt.TextField;rnrnpublic class GridLayoutTest rn Frame frame = null;rn Panel pm = null;rn Panel pc = null;rn Panel ps = null;rn String[] s = "7","8","9","/",rn "sprt","4","5","6",rn "*","%","1","2",rn "3","-","1/x","0",rn "+/-",".","+","=";rn String[] m = "MC","MR","MS","M+";rn String[] c = "Backspace","CE","C";rnButton[] bs = new Button[s.length];rnButton[] bm = new Button[m.length];rnButton[] bc = new Button[c.length];rnTextField tf = new TextField("0.",150);rnrn public GridLayoutTest() rn init();rn rnrn private void init() rn frame = new Frame("计算器 v1.0");rn frame.setLayout(new GridLayout(4,5,3,3));rn for(int i=0;i
main" java.lang.NullPointerException">求助问题:Exception in thread "main" java.lang.NullPointerException
出错祥细:rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at awt.GridLayoutTest.init(GridLayoutTest.java:36)rn at awt.GridLayoutTest.(GridLayoutTest.java:24)rn at awt.GridLayoutTest.<em>main</em>(GridLayoutTest.java:57)rn程序如下:rnpackage awt;rnrnimport java.awt.Button;rnimport java.awt.Color;rnimport java.awt.Frame;rnimport java.awt.GridLayout;rnimport java.awt.Panel;rnimport java.awt.TextField;rnrnpublic class GridLayoutTest rn Frame frame = null;rn Panel pn,pm,pc,ps;rn String[] s = "7","8","9","/",rn "sprt","4","5","6",rn "*","%","1","2",rn "3","-","1/x","0",rn "+/-",".","+","=";rn String[] m = "MC","MR","MS","M+";rnButton[] bs = new Button[s.length];rnButton[] bm = new Button[m.length];rnTextField tf = new TextField("0.",150);rnrn public GridLayoutTest() rn init();rn rnrn private void init() rn frame = new Frame("计算器 v1.0");rn frame.setLayout(new GridLayout(4,5,3,3));rn for(int i=0;i
main" java.lang.NullPointerException问题求助">Exception in thread "main" java.lang.NullPointerException问题求助
问题描述如下:rninit:rndeps-jar:rncompile:rnrun:rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at sun.awt.image.codec.JPEGImageEncoderImpl.getDefaultJPEGEncodeParam(JPEGImageEncoderImpl.java:174)rn at sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:205)rn at waterset.P4.createJpg(P4.java:26)rn at waterset.Main.<em>main</em>(Main.java:77)rnJava Result: 1rn成功生成(总时间:1 秒)rn源程序如下:rnpackage waterset;rnimport java.awt.*;rnimport java.awt.image.*;rnimport java.awt.AlphaComposite.*;rnimport java.io.*;rnimport javax.imageio.ImageIO;rnimport javax.swing.*;rnimport com.sun.image.codec.jpeg.*;rn/**rn *rn * @author Ownerrn */rnpublic class P4 rn BufferedImage image;rnrn public void createJpg(String path) rn try rn FileOutputStream fos = new FileOutputStream(path);rn BufferedOutputStream bos = new BufferedOutputStream(fos);rn JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);rn [color=#FF0000]encoder.encode(image);[/color] rn bos.close(); rn catch(FileNotFoundException fnfe) rn System.out.println(fnfe);rn catch(IOException ioe) rn System.out.println(ioe);rn rn rn public void overlapPictures(BufferedImage p1, BufferedImage p2,int startOverlap)rn int amountOverlap = p1.getWidth() - startOverlap;rn Graphics g =p1.getGraphics();rn Graphics2D g2 = (Graphics2D) g;rn rn g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,(float) 1.0f));rn g2.drawImage(p2,0,0,startOverlap,p1.getHeight(),null);rn g2.drawImage(p1,startOverlap,0,p1.getWidth(),p1.getHeight(),null);rn rn g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.5f));rn rn g2.drawImage(p2,startOverlap,0,p1.getWidth(),p2.getHeight(),0,0,amountOverlap,p2.getHeight(),null);rn rn g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,(float) 1.0f));rn g2.drawImage(p2,p1.getWidth(),0,p2.getWidth()+startOverlap,p2.getHeight(),amountOverlap,0,p2.getWidth(),p2.getHeight(),null);rn rn rnrnrnrnrnrnrn主类:rnpublic class Main rnpublic static void <em>main</em>(String[] args) rn File file1=new File("d:\\1A.jpg");rn File file2=new File("d:\\1B.jpg");rn P4 p1=new P4();rn P4 p2=new P4();rn P4 p3=new P4();rn try rn p1.image = ImageIO.read(file1);rn p2.image = ImageIO.read(file2);rn catch(IOException ioe) rn System.out.println(ioe);rn rn p3.overlapPictures(p1.image,p2.image,0);rn [color=#FF0000]p3.createJpg("d:\\waterset.jpg");[/color] rn rnrnrnrnrn请大家帮我看看<em>怎么</em>回事啊~~~~
main" java.lang.NullPointerException的一个错误">Spark集群 Exception in thread "main" java.lang.NullPointerException的一个错误
[b]在local模式下可以正常运行,放到集群中就出现如下错误:[/b]rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at com.quell.spark.pdfData$.<em>main</em>(pdfData.scala:27)rn at com.quell.spark.pdfData.<em>main</em>(pdfData.scala)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:498)rn at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)rn at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)rn at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)rn at org.apache.spark.deploy.SparkSubmit$.<em>main</em>(SparkSubmit.scala:121)rn at org.apache.spark.deploy.SparkSubmit.<em>main</em>(SparkSubmit.scala)rnrn程序部分如下:[img=https://img-bbs.csdn.net/upload/201612/12/1481530999_818720.jpg][/img]rnrn错误:[img=https://img-bbs.csdn.net/upload/201612/12/1481531017_581415.jpg][/img]rnrnwhile (i < tempList.length) 个人看不出这个问题所在,求大牛相助
main" java.lang.NullPointerException问题求教!">Exception in thread "main" java.lang.NullPointerException问题求教!
下面是源代码出现的异常是rnException in <em>thread</em> "<em>main</em>" java.lang.NullPointerExceptionrn at com.qq.server.db.Text10.(Text10.java:58)rn at com.qq.server.db.Text10.<em>main</em>(Text10.java:39)rn58行是 jp2.add(jb2);,39行是Text10 text= new Text10();求教这问题<em>怎么</em><em>解决</em>??rnrnrnrnpackage com.qq.server.db;rnimport javax.swing.*;rnimport javax.xml.soap.Text;rnrnimport java.awt.*;rnimport java.awt.event.*;rnimport java.util.*;rnimport java.sql.*;rn//完成一个迷你版的用户信息管理系统rnpublic class Text10 extends JFrame implements ActionListenerrn rn JPanel jp1,jp2;rn rn JLabel jl1;rn JButton jb1,jb2,jb3,jb4;rn JTable jt;rn JScrollPane jsp;rn JTextField jtf;rn rn rn Vector rowData, columnNames;rn //rowData用户来存放行数据rn //后者用来存放列明rn rn rn //数据库操作需要定义的变量rn PreparedStatement ps= null;rn Connection ct = null;rn ResultSet rs= null;rn rn String url="jdbc:sqlserver://127.0.0.1:1433;databaseName=QQ";rn String user="sa";rn String passwd="322008";rn /**rn * @param argsrn */rn public static void <em>main</em>(String[] args) rn // TODO Auto-generated method stubrn Text10 text= new Text10();rn rnrn public Text10()rn rn jp1=new JPanel();rn jtf=new JTextField(10);rn jb1 = new JButton("查询");rn jb1.addActionListener(this);rn jl1 = new JLabel("请输入名字:");rn rn jp1.add(jl1);rn jp1.add(jtf);rn jp1.add(jb1);rn rn jb2= new JButton("添加");rn jb3= new JButton("修改");rn jb4= new JButton("注销");rn rn rn jp2.add(jb2);rn jp2.add(jb3);rn jp2.add(jb4);rn rn //中间rn //设置列名rn columnNames= new Vector();rn columnNames.add("号码");rn columnNames.add("昵称");rn columnNames.add("性别");rn columnNames.add("密码");rn columnNames.add("状态");rn rn rowData= new Vector();rn //从数据库读取数据rn rn tryrn //1.加载驱动rn Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");rn ct=DriverManager.getConnection(url,user,passwd);rn rn ps=ct.prepareStatement("select * from personalinfo ");rn rs=ps.executeQuery();rn rn while(rs.next())rn Vector hang = new Vector();rn hang.add(rs.getString(1));rn hang.add(rs.getString(2));rn hang.add(rs.getString(3));rn hang.add(rs.getString(4));rn hang.add(rs.getString(5));rn rn rowData.add(hang);rn rn rn rn catch(Exception e)rn e.printStackTrace();rn finallyrn try rn if(rs!=null)rn rs.close();rn if(ps!=null)rn ps.close();rn if(ct!=null)rn ct.close();rn rn catch (Exception e) rn // TODO: handle <em>exception</em>rn e.printStackTrace();rn rn rn rn jt = new JTable( rowData,columnNames);rn rn jsp= new JScrollPane(jt);rn rn this.add(jsp);rn this.add(jp1,"North");rn this.add(jp2,"South");rn rn this.setVisible(true);rn this.setSize(500, 400);rn this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn rn rn rn
main" java.lang.NoClassDefFoundError :~~ 。怎么解决?">Exception in thread "main" java.lang.NoClassDefFoundError :~~ 。怎么解决
javac通过但java的时候出现了错误,大家帮我看看,为什么会出现这样的错误?根本原因是什么?多谢指教!!rnException in <em>thread</em> "<em>main</em>" java.lang.NoClassDefFoundError:XXXX/class
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
import javax.swing.JFrame;rnimport javax.swing.JScrollPane;rnimport javax.swing.JTable;rnrnpublic class TableTestM extends JFrame rn JTable jTable1;rn JScrollPane jScrollPane1;rnrn public TableTestM() rn jTable1 = new JTable(new MyTableModel(new ContSQL()));rn jScrollPane1 = new JScrollPane(jTable1);rn this.add(jScrollPane1);rn this.pack();rn this.setVisible(true);rn rnrn public static void <em>main</em>(String[] args) rn new TableTestM();rn rnrnrnrnrnrnimport java.sql.Connection;rnimport java.sql.ResultSet;rnimport java.sql.ResultSetMetaData;rnimport java.sql.SQLException;rnimport java.sql.Statement;rnrnimport javax.swing.event.TableModelListener;rnimport javax.swing.table.TableModel;rnrnpublic class MyTableModel implements TableModel rn private ContSQL contSql = null;rn private static ResultSet rs = null;rn private static Statement stmt = null;rn private static Connection conn = null;rn private int rowNum = 0;rn private int colNum = 0;rnrn public MyTableModel(ContSQL contSql) rn this.contSql = contSql;rn try rn stmt = contSql.getStmt();rn rs = stmt.executeQuery("select * from log_tab");rn catch (SQLException e) rn e.printStackTrace();rn rn rnrn public void addTableModelListener(TableModelListener arg0) rn // TODO Auto-generated method stubrn rnrn public Class getColumnClass(int arg0) rn return null;rn rnrn public int getColumnCount() rn ResultSetMetaData rsmd;rn try rn rsmd = rs.getMetaData();rn colNum = rsmd.getColumnCount()-1;rn catch (SQLException e) rn e.printStackTrace();rn rn return colNum;rnrn rnrn public String getColumnName(int i) rn ResultSetMetaData rsmd;rn try rn rsmd = rs.getMetaData();rn return rsmd.getColumnName(i + 1);rn catch (SQLException e) rn e.printStackTrace();rn rn return null;rn rnrn public int getRowCount() rnrn try rn rs.last();rn rowNum=rs.getRow()-1;rn rs.beforeFirst();rn return rowNum;rn catch (SQLException e) rn e.printStackTrace();rn rn return -1;rn rnrn public Object getValueAt(int row, int col) rn try rn if(row==0&&col==0)rn rs.next(); rn rn rn if(row
Exception in thread "Timer-0" java.lang.NullPointerException
Exception in <em>thread</em> "Timer-0" java.lang.NullPointerExceptionrn at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.isLoggable(Log4jMLog. java:255)rn at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResou rcePool.java:1934)rn at java.util.TimerThread.<em>main</em>Loop(Timer.java:534)rn at java.util.TimerThread.run(Timer.java:484)rnException in <em>thread</em> "Timer-1" java.lang.NullPointerExceptionrn at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.isLoggable(Log4jMLog. java:255)rn at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResou rcePool.java:1934)rn at java.util.TimerThread.<em>main</em>Loop(Timer.java:534)rn at java.util.TimerThread.run(Timer.java:484)rnException in <em>thread</em> "Timer-2" java.lang.NullPointerExceptionrn at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.isLoggable(Log4jMLog. java:255)rn at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResou rcePool.java:1934)rn at java.util.TimerThread.<em>main</em>Loop(Timer.java:534)rn at java.util.TimerThread.run(Timer.java:484)rnException in <em>thread</em> "Timer-3" java.lang.NullPointerExceptionrn at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.isLoggable(Log4jMLog. java:255)rn at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResou rcePool.java:1934)rn at java.util.TimerThread.<em>main</em>Loop(Timer.java:534)rn at java.util.TimerThread.run(Timer.java:484)rn^Crn
main" java.lang.NullPointerException这个错误如何解决">Exception in thread "main" java.lang.NullPointerException这个错误如何解决
import javax.swing.*;rnimport java.awt.*;rnclass FrameTest extends JFramernrn public FrameTest()rn rn super("客户信息界面");rn setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn setVisible(true);rn setSize(406,195);rn rn rnrnclass PanelTest extends FrameTestrnrn JPanel panelObj;rn public PanelTest()rn rn panelObj=new JPanel();rn getContentPane().add(panelObj);rn rnrnclass ComponentTest extends PanelTestrnrn JLabel labelName;rn JLabel labelTelNo;rn JLabel labelSex;rn JLabel labelAge;rn JTextField textName;rn JTextField textTelNo;rn JRadioButton rButObj1,rButObj2;rn JPanel subPanelObj;rn JTextField textAge;rn JButton buttonObj;rn public ComponentTest()rn rn labelName=new JLabel("客户名称:");rn labelTelNo=new JLabel("电话号码:");rn labelSex=new JLabel("性别:");rn labelAge=new JLabel("年龄:");rn textName=new JTextField(25);rn textName =new JTextField(15);rn rButObj1=new JRadioButton("男",true);rn rButObj2=new JRadioButton("女",false);rn subPanelObj=new JPanel();rn subPanelObj.add(rButObj1);rn subPanelObj.add(rButObj2);rn ButtonGroup buttonGroupObj=new ButtonGroup();rn buttonGroupObj.add(rButObj1);rn buttonGroupObj.add(rButObj2);rn textAge=new JTextField(3);rn buttonObj=new JButton("录入(L)");rn panelObj.add(labelName);rn panelObj.add(textName);rn panelObj.add(labelTelNo);rn panelObj.add(textTelNo);rn panelObj.add(labelSex);rn panelObj.add(subPanelObj);rn panelObj.add(labelAge);rn panelObj.add(textAge);rn panelObj.add(buttonObj);rn rnrnpublic class CustomerFream01 rnrn public static void <em>main</em>(String args[])rn rn new ComponentTest();rn rnrn大家帮忙看一下我这个有什么错误?
main" java.lang.NoSuchMethodError: main">Exception in thread "main" java.lang.NoSuchMethodError: main
源代码如下:rnpublic class Hellornrnpublic static void <em>main</em>(String args[])rnrnSystem.out.println("Hello World!");rnrnrn请大虾指点rn编译通过,且有Hello.classrn执行java Hello就报这个错误。
main" java.lang.NoSuchMethodError : main">Exception in thread "main" java.lang.NoSuchMethodError : main
rnimport java.util.Arrays;rnimport java.util.*;rnimport javax.swing.*;rn class circle rnrn private double r;rn public circle(double radius)rn rn r=radius;rn rnrnrnpublic class elevenrn rn public static void <em>main</em>(String args[])rn rn circle c1=new circle(2);rn circle c2=new circle(10);rn circle c3=new circle(8);rn circle c4=new circle(4);rn circle c5=new circle(12); rn circle[] c;rn c=new circle[5];rn c[0]=c1;rn c[1]=c2;rn c[2]=c3;rn c[3]=c4;rn c[4]=c5; rn double d[];rn d=new double[5];rn d[0]=2;rn d[1]=4;rn d[2]=8;rn d[3]=10;rn d[4]=12;rn Arrays.sort(c);rn int i;rn for(i=0;i<5;i++)rn rn System.out.println(d[i]);rn rn rn rnrn
main" java.lang.NoSuchMethodError:main">Exception in thread "main" java.lang.NoSuchMethodError:main
rn//用冒泡法进行排序rnrnpublic class paixvrnrnint shuzhi[]=1,25,84,69,325,68,42;rnint num=0; rnint temp=0;rnrnpublic void <em>main</em>(String arg[])rnrnfor (num=1;numshuzhi[num+1]) rn rn rn temp=shuzhi[num];rn shuzhi[num]=shuzhi[num+1];rn shuzhi[num+1]=temp;rn rn rnfor (num=1;num java.lang.NoSuchMethodError:<em>main</em>
main"">java.lang.NoSuchMethodError: main Exception in thread "main"
[code=Java]rnpublic class Test rnrn /**rn * @param argsrn */rn public static void <em>main</em>(String[] args) rn Date date = new Date();rn String dates = String.format(null, "%tF", date);rn System.out.println(dates);rn rnrnrn[/code]rn这是程序。我也从网上查了好久。都说是没有<em>main</em>方法。rn还是没<em>解决</em> 。请教大虾了。。rn什么原因?<em>怎么</em>改?
main" java.lang.NoClassDefFoundError:">Exception in thread "main" java.lang.NoClassDefFoundError:
编译通过rn在执行时出现如下错误是什么原因:rnException in <em>thread</em> "<em>main</em>" java.lang.NoClassDefFoundError:rnrnrn
main" java.lang.OutOfMemoryError">Exception in thread "main" java.lang.OutOfMemoryError
都有什么原因能引起这种异常!rn我的这段代码大概如下:其中是vec是Vector类型的entry是自定义的对象,s2i是将String转化为int的函数,去掉这段代码就可以运行了,rnrnfor (int i = 0; i < vec.size() - 1 ; i++ )rnrnEntry this_entry = (Entry)vec.elementAt(i);rnEntry next_entry = (Entry)vec.elementAt(i+1);rnrnString this_s_time = this_entry.getStart_time();rnString this_e_time = this_entry.getEnd_time();rnint this_edaban = this_entry.getEdaban();rnrnrnString next_s_time = next_entry.getStart_time();rnString next_e_time = next_entry.getEnd_time();rnint next_edaban = next_entry.getEdaban();rn rnrnrnif (s2i(next_s_time) < s2i(this_e_time))rnrn if (this_edaban < next_edaban)rnrnnext_entry.setStart_time(this_e_time);rnvec.setElementAt(next_entry, i+1);rnrnelsernrnthis_entry.setEnd_time(next_s_time);rnvec.setElementAt(this_entry, i);rnrnrnif (s2i(next_s_time) > s2i(this_e_time))rnint add_cellCount = getCellCount(next_s_time, this_e_time);rnEntry add_entry = new Entry(this_e_time, next_s_time, add_cellCount);rnvec.insertElementAt(add_entry, i+1);rnrnrnrn
main"">java.lang.NoClassDefFoundError: Exception in thread "main"
刚开始学习并发 遇到一个问题,请高手帮忙<em>解决</em>rnrn//LiftOff.javarn public class LiftOff implements Runnablern protected int countDown=10;rn public static int taskCount=0;rn private final int id =taskCount++;rn public LiftOff()rn public LiftOff(int countDown)rn this.countDown=countDown;rn rn rn public String status()rn return "#"+id+"("+rn (countDown>0?countDown:"LiftOff!")+"), ";rn rn public void run()rn while(countDown0)rn System.out.println(status());rn Thread.yield();rn rn rn rn rnrn//MainThread.javarnpublic class MainThread rnrn public static void <em>main</em>(String[] args) rn // TODO 自动生成方法存根rn rn LiftOff launch=new LiftOff();rn launch.run();rn rn rnrnrn1在eclipse中运行输出java.lang.NoClassDefFoundError ,同一包中的其他程序运行无异常rn2使用命令编译运行无误rn<em>怎么</em><em>解决</em>rnrnrn
exception in thread main???
java.lang.NoClassDefFoundErrorrn请问是<em>怎么</em>回事?多谢!
main" org.springframework.beans.factory.BeanCreationExcep">Exception in thread "main" org.springframework.beans.factory.BeanCreationExcep
Exception in <em>thread</em> "<em>main</em>" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [D:\work\travl\target\classes\spring-mybatis.xml]: Initialization of bean failed; nested <em>exception</em> is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested <em>exception</em> is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/hbnu/travl/mapping/*.xml]: class path resource [com/hbnu/travl/mapping/] cannot be resolved to URL because it does not existrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:681)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)rn at com.hbnu.travl.control.TestControl.<em>main</em>(TestControl.java:44)rnCaused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested <em>exception</em> is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/hbnu/travl/mapping/*.xml]: class path resource [com/hbnu/travl/mapping/] cannot be resolved to URL because it does not existrn at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:479)rn at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)rn at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)rn ... 11 morernCaused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/hbnu/travl/mapping/*.xml]: class path resource [com/hbnu/travl/mapping/] cannot be resolved to URL because it does not existrn at org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText(ResourceArrayPropertyEditor.java:140)rn at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:430)rn at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:403)rn at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:181)rn at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)rn ... 17 morernrnrnrnrnrnrnrnrnrnrnrnrnrn请问大神<em>怎么</em>回事rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn rnrnrn
main"">Exception in thread "main"
JAVA新手,写了一个计算复数加减乘除的程序,没有语法错误,却出现了运行错误,找不出相应的错误,请指教!rn以下是代码:rnclass Complexrnrn // a为实部,b为虚部rn private double a;rn private double b;rn rn public Complex()rn rn rn rn public Complex(double a, double b)rn rn this.a = a;rn this.b = b;rn rn rn // 设置相关属性rn public void setA(double a)rn rn this.a = a;rn rn public void setB(double b)rn rn this.b = b;rn rn rn // 得到相关属性rn public double getA()rn rn return a;rn rn public double getB()rn rn return b;rn rn rn // 重写Object类的toString()方法rn public String toString()rn rn return "(" + a + " + " + b + "i)";rn rnrnpublic class ComplexTestrnrn private static Complex c;rn public static Complex add(Complex c1, Complex c2)rn rn c = null;rn c.setA(c1.getA() + c2.getA());rn c.setB(c1.getB() + c2.getB());rn return c;rn rn public static Complex subtract(Complex c1, Complex c2)rn rn c = null;rn c.setA(c1.getA() - c2.getA());rn c.setB(c1.getB() - c2.getB());rn return c;rn rn public static Complex multiply(Complex c1, Complex c2)rn rn c = null;rn c.setA(c1.getA() * c2.getA() - c1.getB() * c2.getB());rn c.setB(c1.getB() * c2.getA() + c1.getA() * c2.getB());rn return c;rn rn public static Complex divide(Complex c1, Complex c2)rn rn c = null;rn c.setA((c1.getA() * c2.getA() + c1.getB() * c2.getB()) /rn (c2.getA() * c2.getA() + c2.getB() * c2.getB()));rn c.setB((c1.getB() * c2.getA() - c1.getA() * c2.getB()) /rn (c2.getA() * c2.getA() + c2.getB() * c2.getB()));rn return c;rn rn public static void <em>main</em>(String args[])rn rn Complex c1 = new Complex(1, 2);rn Complex c2 = new Complex(3, 4);rn System.out.println(add(c1, c2));rn System.out.println(subtract(c1, c2));rn System.out.println(multiply(c1, c2));rn System.out.println(divide(c1, c2));rn rn rnrn
netFunc网络函数大全下载
delphi网络函数大全: 获取本地ip失败 获取主机名失败 获取SQLServer服务器失败 获取共享资失败 获取所有工作组失败 获取工作组中所有计算机失败 获取所有网络类型失败 网络不通 未登入网络 网络畅通 已登入网络 上网了 相关下载链接:[url=//download.csdn.net/download/fsm_hawking/1979347?utm_source=bbsseo]//download.csdn.net/download/fsm_hawking/1979347?utm_source=bbsseo[/url]
udiskkillerU盘病毒终结者下载
udiskkillerU盘病毒终结者 可牛提供的清理U盘病毒、恢复隐藏文件的专杀工具 相关下载链接:[url=//download.csdn.net/download/kxf1990/2488906?utm_source=bbsseo]//download.csdn.net/download/kxf1990/2488906?utm_source=bbsseo[/url]
程序员2011年2月刊物 第一部分下载
请把3部分下全请把3部分下全请把3部分下全请把3部分下全请把3部分下全请把3部分下全请把3部分下全请把3部分下全请把3部分下全 相关下载链接:[url=//download.csdn.net/download/jefferwind/3072459?utm_source=bbsseo]//download.csdn.net/download/jefferwind/3072459?utm_source=bbsseo[/url]
相关热词 c# gdi 占用内存 c#中遍历字典 c#控制台模拟dos c# 斜率 最小二乘法 c#进程延迟 c# mysql完整项目 c# grid 总行数 c# web浏览器插件 c# xml 生成xsd c# 操作sql视图
我们是很有底线的