java.lang.Nullnonepointerexceptionn null

NullPointerException (Java Platform SE 7 b99)
JavaScript is disabled on your browser.
Please note that the specifications and other information contained herein are not final and are subject to change. The information is being made available to you solely for purpose of evaluation.
Class NullPointerException
java.lang.NullPointerException
All Implemented Interfaces:
public class NullPointerException
Thrown when an application attempts to use null in a
case where an object is required. These include:
Calling the instance method of a null object.
Accessing or modifying the field of a null object.
Taking the length of null as if it were an array.
Accessing or modifying the slots of null as if it
were an array.
Throwing null as if it were a Throwable
Applications should throw instances of this class to indicate
other illegal uses of the null object.
NullPointerException objects may be constructed by the
virtual machine as if .
Constructor Summary
Constructors&
Constructor and Description
Constructs a NullPointerException with no detail message.
Constructs a NullPointerException with the specified
detail message.
Method Summary
Methods inherited from class&java.lang.
, , , , , , , , , , , ,
Methods inherited from class&java.lang.
, , , , , , , , ,
Constructor Detail
NullPointerException
public&NullPointerException()
Constructs a NullPointerException with no detail message.
NullPointerException
public&NullPointerException(&s)
Constructs a NullPointerException with the specified
detail message.
Parameters:s - the detail message.
For further API reference and developer documentation, see . That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
© , Oracle and/or its affiliates.
All rights reserved. Use is subject to . Also see the . DRAFT&ea-b99
Scripting on this page tracks web page traffic, but does not change the content in any way.Add Deployment
java.lang.NullPointerException - 编程足球 - ITeye技术网站
博客分类:
1. 在用Myeclipse部署项目时候突然报错:
无法进行部署操作
2. 原因1. 可能是你的Web-root的值不对。通过右击项目-&Properties-&MyEclipse-&Web
&& 查看自己的web根目录是否正确。
&&& 发现Web-root 的值为 WebRoot 和 项目的 web 不一致。可会导致上面的错误。
3. 解决方法: 在项目路径目录下找到 .mymetadata 打开
&?xml version="1.0" encoding="UTF-8"?&
&project-module
type="WEB"
name="wlms"
id="myeclipse.7"
context-root="/wlms"
j2ee-spec="1.4"
archive="wlms.war"&
&attributes&
&attribute name="webrootdir" value="/WebRoot" /&
&/attributes&
&/project-module&
修改配置项
&attributes&
&attribute name="webrootdir" value="/WebRoot" /&
&/attributes&
&attributes&
&attribute name="webrootdir" value="/web" /&
&/attributes&
保存。。重新启动Myeclipse就可以了
浏览: 97640 次
来自: 福州
也就是导出。。。如何把生成的图片导出到本地,有没有接口?
你好,请问生成的图片如何保存到本地?
楼主,为啥放进去后,我下载的中文文件名还是乱码呢?
下载之后使用了,没有解决上传时中文名字乱码问题,请博主指导。java.lang.NULLPointerException这个异常是什么意思?什么情况下会产生?如何解决?
[问题点数:0分]
java.lang.NULLPointerException这个异常是什么意思?什么情况下会产生?如何解决?
[问题点数:0分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
本帖子已过去太久远了,不再提供回复功能。Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. J it only takes a minute:
I'm developing an Android application that uses Fragments. I got this error.
Caused by: java.lang.NullPointerException: name == null
What does name == null mean? Here's the full log
08-04 15:02:22.422: E/AndroidRuntime(2499): FATAL EXCEPTION: main
08-04 15:02:22.422: E/AndroidRuntime(2499): java.lang.RuntimeException: Unable to start activity ComponentInfo{fi.peltoset.mikko.home/fi.peltoset.mikko.home.Koti}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.os.Looper.loop(Looper.java:137)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.ActivityThread.main(ActivityThread.java:4745)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at java.lang.reflect.Method.invokeNative(Native Method)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at java.lang.reflect.Method.invoke(Method.java:511)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at dalvik.system.NativeStart.main(Native Method)
08-04 15:02:22.422: E/AndroidRuntime(2499): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.Activity.setContentView(Activity.java:1867)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at fi.peltoset.mikko.home.Koti.onCreate(Koti.java:13)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.Activity.performCreate(Activity.java:5008)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-04 15:02:22.422: E/AndroidRuntime(2499):
... 11 more
08-04 15:02:22.422: E/AndroidRuntime(2499): Caused by: java.lang.NullPointerException: name == null
08-04 15:02:22.422: E/AndroidRuntime(2499):
at java.lang.VMClassLoader.findLoadedClass(Native Method)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:354)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at java.lang.ClassLoader.loadClass(ClassLoader.java:491)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.Fragment.instantiate(Fragment.java:574)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.Fragment.instantiate(Fragment.java:552)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.app.Activity.onCreateView(Activity.java:4656)
08-04 15:02:22.422: E/AndroidRuntime(2499):
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
08-04 15:02:22.422: E/AndroidRuntime(2499):
... 21 more
This is in a class called Navigation. It extends android.app.Fragment.
In it's onCreateView method I inflate the layout and return it. In the onActivityCreated method I check if the layout has two panes (I have different layouts for different devices) and based on that I add onClickListeners to these.
My code looks like this.
public class Navigation extends Fragment {
private OnItemSelectedL
private boolean dualPane =
public interface OnItemSelectedListener {
public void onMenuItemSelected(int fragmentId);
public void onAttach(Activity activity) {
super.onAttach(activity);
if(activity instanceof OnItemSelectedListener) {
this.listener = (OnItemSelectedListener)
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_navigation, container, false);
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View contentPane = getActivity().findViewById(R.id.contentFragment);
dualPane = contentPane != null && contentPane.getVisibility() == View.VISIBLE;
if(dualPane) {
final ListView menu = (ListView) getActivity().findViewById(R.id.valikko);
menu.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
String[] texts = new String[] {
ArrayList&MenuItem& items = new ArrayList&MenuItem&();
items.add(new MenuItem("Home", R.drawable.koti2));
ImageArrayAdapter adapter = new ImageArrayAdapter(getActivity(), items, texts);
menu.setAdapter(adapter);
menu.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView&?& parent, View view, int position, long id) {
String item = ((TextView) view.findViewById(R.id.label)).getText().toString();
listener.onMenuItemSelected(0); // TODO ...
ImageView btnYleiskatsaus
= (ImageView) getActivity().findViewById(R.id.btnYleiskatsaus);
btnYleiskatsaus.setOnClickListener(onMenuClikkedListener);
private OnClickListener onMenuClikkedListener = new OnClickListener() {
public void onClick(View v) {
The layout file layout-sw720dp-land/activity_navigation.xml looks this
&LinearLayout
xmlns:android="/apk/res/android"
xmlns:tools="/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pressed_koti"
android:orientation="vertical" &
android:id="@+id/valikko"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" &
&/ListView&
&/LinearLayout&
Here is the activity_koti.xml file.
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" &
android:id="@+id/menuFragment"
android:layout_width="300dp"
android:layout_height="match_parent"
class="fi.peltoset.mikko.home.Navigation" /&
android:id="@+id/contentFragment"
android:layout_width="fill_parent"
android:layout_height="match_parent" /&
&/LinearLayout&
I ran the application on an emulator with Android 4.1.2.
What causes these errors and how do I fix them?
1,11442559
You should use android:name to point to your fragments instead of class, it is also necessary to include the same attribute for your second fragment, this would explain the name==null.
Edit: , but I would follow what the docs use.
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" &
android:id="@+id/menuFragment"
android:layout_width="300dp"
android:layout_height="match_parent"
android:name="fi.peltoset.mikko.home.Navigation" /&
android:id="@+id/contentFragment"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:name="I NEED A NAME" /&
&/LinearLayout&
2,67411123
When you add a fragment in the XML file, you need to give it a name attribute. That's why it says "name = null", because you're not doing that.
14.6k32764
Try adding a class to your second fragment in activity_koti.xml if you're referencing it in your FragmentActivity.
Or, as Robadob says, add android:name:"your.path.YourName" to both.
Interesting additional info on class vs android:name in XML references to Fragments .
You should debug the code watching the variables and determining where and when name gets null, and why. Every null pointer error has a common solution, debugging and tracing.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Top questions and answers
Important announcements
Unanswered questions
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 nullpointerexception 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信