Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception throwing when working with jar

 
Abhijith Sugunan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a project in netbeans with SQLite as DB.When i run it within netbeans it
works perfectly when i run the jar using "java -jar <jarname>.jar" it throws this exception


H:\>java -jar Remote_PC_Manger.jar
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.halorpm.main.LocalDB.checkAnonymous(LocalDB.java:74)
at com.halorpm.main.MainForm.initComponents(MainForm.java:172)
at com.halorpm.main.MainForm.<init>(MainForm.java:137)
at com.halorpm.main.Core.<init>(Core.java:32)
at com.halorpm.main.Core$3.run(Core.java:142)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)




 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is right there in the error message (and it has nothing to do with sockets).



What's line 74 of LocalDB.java?
 
Abhijith Sugunan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:The answer is right there in the error message (and it has nothing to do with sockets).



What's line 74 of LocalDB.java?


LocalDB ob = new LocalDB();
int res = ob.checkAnonymous();
if(res==1) {

jCheckBox1.setSelected(true);

}

Actually it's work fine in ide and i run the executable jar it throws this exception
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is line 74?
 
Abhijith Sugunan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:Which is line 74?


int res = ob.checkAnonymous()
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhijith Sugunan wrote:
Jeff Verdegan wrote:Which is line 74?


int res = ob.checkAnonymous()


Then ob is null.

If it works in one environment and not the other, then it's probably either a timing issue with multithreaded code, or you've tried to load a class that's not on your classpath (but was in the other environment) and have swallowed the resulting ClassNotFoundException.
 
Paul Clapham
Sheriff
Posts: 21298
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhijith Sugunan wrote:
Jeff Verdegan wrote:Which is line 74?


int res = ob.checkAnonymous()


That line of code isn't even in LocalDB.java, at least not in the version you posted. Let's try again.

What is line 74 of LocalDB.java?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
That line of code isn't even in LocalDB.java, at least not in the version you posted. Let's try again.

What is line 74 of LocalDB.java?


Abhijith, I realize you're new to programming, so here's an important lesson. More important than learning any particular language syntax. Precision and attention to detail are cruicial.

You have to pay attention to the details of what error messages are saying, both at compile time and at runtime.

You have to pay attention to the details of what others are saying when they're making suggestions or asking you questions.

You have to be very precise in what you say to others when describing a plan or a problem.

If you don't do these things, misunderstandings--between you and others, and between you and the computer--will prevent you from making progress.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic