I am trying to write an excel file in a directory that the user will selected with a JFileChooser which is already working well.  My problem is that, when I am passing the path to a String:      private void JFileChooserExcActionPerformed(java.awt.event.ActionEvent evt) {                                                     JFileChooserExc.setCurrentDirectory(new java.io.File("."));     JFileChooserExc.setFileSelectionMode(JFileChooserExc.DIRECTORIES_ONLY);     JFileChooserExc.setAcceptAllFileFilterUsed(false);      if (JFileChooserExc.showOpenDialog(this) == JFileChooserExc.APPROVE_OPTION) {         try {             String path = JFileChooserExc.getSelectedFile().getAbsolutePath(); //Here is the problem             Rank(path);         } catch (IOException ex) {             Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);         }     } }   I receive the next exception:     "AWT-EventQueue-0" java.lang.NullPointerException   And the program broke.  I search for many websites and it looks like my code is fine. Any help with be appreciate.
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Probability of first actor winning a "first to roll seven with two dice" contest? Integral solutions of hyperboloid $x^2+y^2-z^2=1$ Are there integral solutions to the equation $x^2+y^2-z^2=1$? Given six numbers $x,y,z,a,b,c$ which satisfy the following relations. Express $x+y+z$ in terms of $a,b,c$ Given six numbers $x,y,z,a,b,c$ which satisfy the following relations $y^2+yz+z^2=a^2$ $z^2+zx+x^2=b^2$ $x^2+xy+y^2=c^2$ Express $x+y+z$ in terms of $a,b,c$    My attempt: $\dfrac{(y^3-z^3)}{(y-z)}=a^2,\dfrac{(z^3-x^3)}{(z-x)}=b^2,\dfrac{(x^3-y^3)}{(x-y)}=c^2$ But this step didn't seem to help. So I tried adding and expressing $k(a+b+c)^2$ but some other unmanagable elements came along. I could not think of any other way to approach the problem. Please help. Upload images from the Stack Exchange Android app I would like to request implementation of uploading images to questions/answers from the Stack Exchange Android app, especially now as it would definitely help uploading screenshots for reporting bugs and feature requests. Video grid with vstack and hstack MySQL: How to retrieve a random row or multiple random rows? Was Louis stalked days in advance too? Where's my 5 minute grace period gone? I just posted an answer. (Revision history .)  I edited it a few seconds later (within my 5 minute grace period), and it comes up as a new revision!? Why?    ^^You can see 'answered 1 min ago', and then 'edited 1 min ago' - how is that possible?  Additionally, !?    I don't think this is a dupe of . See my comments on AI.E's answer. If you're a mod, it will really help. Redirect STDERR and STDOUT to different variables without temporary files I am using a Collection (a HashMap used indirectly by the JPA, it so happens), but apparently randomly the code throws a ConcurrentModificationException. What is causing it and how do I fix this problem? By using some synchronization, perhaps?  Here is the full stack-trace:  Exception in thread "pool-1-thread-1" java.util.ConcurrentModificationException         at java.util.HashMap$HashIterator.nextEntry(Unknown Source)         at java.util.HashMap$ValueIterator.next(Unknown Source)         at org.hibernate.collection.AbstractPersistentCollection$IteratorProxy.next(AbstractPersistentCollection.java:555)         at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)         at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)         at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)         at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)         at org.hibernate.engine.Cascade.cascade(Cascade.java:130) Which is correct, "neither is" or "neither are"? I was wondering about the reason of the choose of the X as symbol used to represents the "Close application" operation. $1+a$ and $1-a$ in a ring are invertible if $a$ is nilpotent How to flash a BIOS when only a Windows binary is provided? find spectrum matrix A Let $A = \left[ \begin{array}{*{20}{c}} 0&amp;b&amp;0&amp;0&amp;0&amp;0\\ c&amp;0&amp;b&amp;0&amp;0&amp;0\\ 0&amp;c&amp;0&amp;b&amp;0&amp;0\\ 0&amp;0&amp;c&amp;0&amp;b&amp;0\\ 0&amp;0&amp;0&amp;c&amp;0&amp;b\\ 0&amp;0&amp;0&amp;0&amp;c&amp;0 \end{array} \right]_{n \times n}$.  Why does matrix $A$ have spectrum $\sigma (A) = \left\{ 2\sqrt {bc} \cos \left(\frac{\pi k}{n + 1}\right):k = 1,2,\ldots,n \right\}$? How to diff a commit with its parent? Aside from writing an alias or script, is there a shorter command for getting the diff for a particular commit?  git diff 15dc8^..15dc8   If you only give the single commit id git diff 15dc8, it diffs that commit against HEAD. Minkowski Metric Signature When I learned about the Minkowski Space and it's coordinates, it was explained such that the metric turns out to be $$ ds^{2} = -(c^{2}dx^{0})^{2} +(dx^{1})^{2} + (dx^{2})^{2} + (dx^{3})^{2}   $$ where $ x^0,x^1,x^2,x^3 $ come from $ x^{\mu} : \mu = 0,1,2,3 $, and $ c $ is the speed of light. The first resource I had access to--I have to do a bit of digging for the exact paper--of course addressed that this invariant takes the tensor form: $$ ds^2 = g_{\mu \nu}dx^{\mu}dx^{\nu} $$ as well. This two things I've seen in all of my texts and online resources regarding resources. The element in question that varies between authors, is the time coordinate, $ x^0 $. When it was first explained to me, it was using the standard Cartesian representation for the spatial portion of the coordinates, and the time coordinate was labeled as $ x^0 = ict $. Squaring gives $ (x^0)^2 = -c^2t^2 $, and applying differential calculus, we get $ (dx^0)^2 = -c^2dt^2 $. Sensible and expected to have the tensor formula spit out the Minkowski Metric. The author then later explicitly states the coordinates are $ x^0 = ict, x^1=x,x^2=y,$ and $x^3 = z$.  My questions is then, why is it most authors on the subject omit the imaginary unit on the time coordinate? For example, .   The only reason I can fathom omission is if the author is using metric signature $ [+,-,-,-] $, where I started off learning the theory with signature $ [-,+,+,+] $ which may be the reason seeing the time coord with no imaginary unit seems dissonant to me. All help appreciated!  Edit: After reading the other answers, my questions is now one of why and how (mathematically) do we obtain the Minkowski Metric Signature. More specifically the one element with a different sign. How to set security options for a PDF using pdflatex My questions is very simple. How can I set security setting for a PDF file created with PDFLatex?  I should set some password or print permissions, etc. How to add a matrix to a LaTeX document How do we add a matrix to a LaTeX document? How do I give text or an image a transparent background using CSS?