Skip to content

null pointer exception error calling method

I get this null pointer exception error if i call a method. if (farm1.cropStat(row, col) ) here’s the method here’s the initialization pls help 🙁 Answer Whenever you see a pattern that looks like this replace it with the equivalent It is the same thing. As far as the error goes, you need to revers…

JPA @Column annotation to create comment/description

I was wondering is it possible to create from jpa/hibernate annotation a database column description/comment like this: ALTER TABLE tablename CHANGE status status INT(11) NOT NULL COMMENT ‘sample description/comment’; It will be great functionality, but I cant find anything about this in JPA speci…

Logging from default interface methods

Salut to all Java gurus! Since Java8 we can have default implementations in interfaces (yay!). However problem arises when you want to log from default method. I have a feeling that it is not wise to call .getLogger() every time I want to log something in a default method. Yes, one can define static variable …

How to deal with Sessions in Google App Engine?

I am successfully creating sessions in servlet and I can get sessions/ session attribute to jsp but not in endpoints class. I want to get the sessions info in endpoints classes. Please help me with this. I am using maven in eclipse and I enabled sessions in appengine-web.xml I read an article about this also …

How to get the path of src/test/resources directory in JUnit?

I know I can load a file from src/test/resources with: But how can I get the full path to the src/test/resources directory, i.e. I don’t want to load a file, I just want to know the path of the directory? Answer Try working with the ClassLoader class: A ClassLoader is responsible for loading in classes.…

Java JScrollPane scrolls to bottom… almost

I have a ScrollPane with a JPanel in my Java program that gets alot of text appended. I need the ScrollPane to scroll to the very bottom after every addition. My problem with the following code is that it scrolls “almost” to the bottom but not all the way. Any ideas as to what I am doing wrong? An…

How to ignore Exceptions in Java

I have the following code: I would like to execute: test.setSomething2(0); even if test.setSomething(0) (the line above it) throws an exception. Is there a way to do this OTHER than: I have a lot of test.setSomething’s in a row and all of them could throw Exceptions. If they do, I just want to skip that…