Skip to content
Advertisement

Make immutable Java object

My goal is to make a Java object immutable. I have a class Student. I coded it in the following way to achieve immutability: My question is, what is the best way to achieve immutability for the Student class? Answer Your class is not immutable strictly speaking, it is only effectively immutable. To make it immutable, you need to use

Tycho cannot resolve fragment dependency on other fragment

I want to create an extension for org.eclipse.swt as a fragment. I have created a bundle swt.extension with the following MANIFEST.MF: Also, I have created an interface which extends an interface from SWT: When I build my project with tycho (mvn clean install) the following error occurs: It seems that tycho resolves only org.eclipse.swt jar. This is a host bundle

Where to add compiler options like -ea in IntelliJ IDEA?

I want to add the -ea option. I set it in Project Settings –> Compiler –> Java Compiler : Additional command line parameters. But it caused a make error: invalid flag: -ea. P.S.: the above error message may not be the same as yours, because IntelliJ showed error in my native language, not English. I translated it into English. Answer

Frontend Bug Reporting plugin for Website Beta Tester

I am looking for a bug reporting solution that I can embed into my website. I would like allow users to report front end issues directly from the page and be able to capture screen clippings, ideally it would also have some kaptcha to prevent basic spamming. I have an issue tracker, I want to ease the reporting process to

In Activity.onCreate(), why does Intent.getExtras() sometimes return null?

This was probably a false alarm, see my own answer. Original question below: An activity has a button that takes the user to another activity. To launch the new activity, we populate our Intent with extras, and onCreate(), the new activity reads from those extras via Intent.getExtras(). We assumed the returned bundle would be non-null, but as customer crash reports

Cannot inherit from final class error

What does this error mean .. It runs fine in Eclipse but not in intellij idea I get this error when I try to run couchbase using couchbase-client-1.1.6.jar from Intellij IDea. Answer if you’re using kotlin, add open to your class (extends RealmObject) declaration

Set the heap size of java with Garbage collection enabled

I am running JVM in a ubuntu ec2 instance which runs only solr and nothing else. Now I wanna configure the Heap size of the JVM which is running. The problem is I am not using Sun Jdk I am using the following versions and settings How do I reset the heap size to my requirements.Also I want to enable

java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit

I’m working on XUbuntu 13.04 and developing swing applications. As I just wanted to try that application I ran into java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit on startup. I’ve found several questions about server/client vms and noticed that I have a server VM and that for Linux 64 there is no client VM anymore. But nevertheless IMHO this problem shouldn’t

What does “Could not find or load main class” mean?

A common problem that new Java developers experience is that their programs fail to run with the error message: Could not find or load main class … What does this mean, what causes it, and how should you fix it? Answer The java <class-name> command syntax First of all, you need to understand the correct way to launch a program

A strange UnknownHostException

In a web project . I see the log: but when I ping example.com, it’s ok, I also telnet example.com 2181 successfully! I found the similar question so I run the DomainResolutionTest in my Server java DomainResolutionTest example.com but it’s ok ! env: java version “1.6.0_25” Java(TM) SE Runtime Environment (build 1.6.0_25-b06) Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed

Advertisement