Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

Share tech news, updates, or what's on your mind.

Sign up to Post

When I try to update a document exists on SOLR7 I got this message:

TransactionLog doesn't know how to serialize class java.util.UUID; try
implementing ObjectResolver?

With the stack trace:

doesn't know how to serialize class java.util.UUID; try implementing 
TransactionLog doesn't know how to serialize class java.util.UUID; try 
implementing ObjectResolver?\n\tat 

Open in new window

Exploring SharePoint 2016
LVL 13
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Our application built with C# and SOLR search.

One of my requirement to implement partial updates with SOLR.I am getting an error while posting JSON data into SOLR server.

Error Response from SOLR API:

    "responseHeader": {
        "status": 400,
        "QTime": 30
    "error": {
        "metadata": [
        "msg": "Atomic document updates are not supported unless <updateLog/> is configured",
        "code": 400

Open in new window

Any idea how to fix the following compile error : error: unreported exception NegativeNumberException; must be caught or declared to be thrown
                                throw e;
Would anyone wish to comment on the algorithm here, which finds the GCDs of two numbers? (I'm not asking about number format exceptions etc., just the math and algo elements).

import java.util.*;

class Euclid {

int m;
int n;
int commonDivisor;

    public static void main(String[] args){
            Scanner scanner  = new Scanner(;
            System.out.print("Number for higher figure > ");
            Integer higher = new Integer(scanner.nextInt());
            System.out.print("Number for lower figure > ");
            Integer lower = new Integer(scanner.nextInt());
            Euclid euclid = new Euclid();
            euclid.n = lower.intValue();
            euclid.m = higher.intValue();
            euclid.commonDivisor = euclid.findLargestCommonDivisor(euclid.m, euclid.n);
            if(euclid.commonDivisor == -1){System.out.println("These numbers, (or, at least, the higher of the two is), or are, prime. They have no (greatest) common divisor.");}
            else{System.out.println("The largest number that divides both "+euclid.m+" and "+euclid.n+" "+"is . . . . "+euclid.commonDivisor);}

    private int findLargestCommonDivisor(int m, int n){
        int n1 = 0;
        int nPrev = 0;
        if(m % n == 0){
            return n;

Open in new window

I came across the following in the book java concurrency in practice :
Frankly speaking i dont understand why all of these conditions are required.
Unable to find any reasons for all this.

Please help me understand it.

Hi Team,

I need an help in compiling my java program. I do not have admin writes to set the path variable in my system to point to JDK installed directory.
I need to compile my file in D:\JavaProject folder. My JDK is installed in the c:\Program Files\Java\JDK1_8\bin

From D:\JavaProject folder I need to run  javac command

Iam getting the below error
unrecognised command  for javac

is there a way to compile the code without having to set the path variable  and mention the JDK path in javac command. Its very urgent

javac  <path of JDK>
I have the following program :
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test implements  Runnable{
    private static SynchronizedInteger synchronizedInteger = new SynchronizedInteger();

    public static void main(String[] args) {
        ExecutorService executor = Executors.newFixedThreadPool(5);
        Runnable runnable = new Test();
        System.out.println("After runnable");
        System.out.println("After set 100");

    public void run() {
        while(synchronizedInteger.get()!=100) {
            System.out.println("not 100");
        System.out.println("its 100");

Open in new window

The program prints the following :
not 100
not 100
After runnable
After set 100
not 100
its 100

But after that doesnt exits.
Why is that ? I guess something related to the thread that is started with executor.execute(runnable)
But dont know the exact reason

For sending requests to a webservice that deserializes Json, what items in this list are 'required' by the webservice?

# BasicAuthUser:
# BasicAuthPassword:
# ProxyURI:
# ProxyUser:
# ProxyPassword:
# SendHTTPHeaders:
# HeaderCookieData:
# ResponseCookieFile:
# HeaderSOAPAction:
# HeaderUserAgent:
# HeaderAccept:
# HeaderHost:
# HeaderReferer:
# HeaderConnection:
# HeaderContentType:
# CustomHeaderName(1): Authorization
# CustomHeaderValue(1):
# InputCcsid: 0
# OutputCcsid: 0
# EnableExpectHeader:  
# LocalInterface:
# Enable IPv6:
I've got a reasonable knowledge of Java, but this quote from Java in a Nutshell 6th Ed., seems a bit unsettling for some reason to me :

The following code shows that even after a call to manipulate(), the value contained in variable c is unaltered - it is still holding a reference to
a Circle object of radius 2. If Java was [sic] a pass-by-reference language, it would instead be holding a reference to a radius 3 Circle:

public void manipulate(Circle circle){
        circle = new Circle(3);
    Circle c = new Circle(2);
    System.out.println("Radius: "+ c.getRadius());

Open in new window

 . . . when contextualised thusly :

class RefDemo {

Circle c;

    public int /*void*/ manipulate(Circle circle){
        circle = new Circle(3);
        return circle.getRadius();

    public RefDemo(){this.c = new Circle(2);}
    public static void main(String[] args){
        RefDemo rd = new RefDemo();
        System.out.println("Radius: "+ rd.c.getRadius());

  public class Circle {
  private int radius;
    public Circle(int r){
        this.radius = r;
    public int getRadius(){return this.radius;}

Open in new window

Hi Experts,

could you suggest the best way to convert custom application text log file to json format please

Read the whole file and convert line by line to json on a windows server.

Since application generate log in its custom location, may be I should read this directory for each file > convert each line to json object, place it in a different location. Also we should not duplicate or read the same line again :)

Also is it possible to apply similiar logic to windows events log.

please advice
Introduction to R
LVL 13
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

I am currently learning Java.

I would like to create a class that contains a constant variable (it should not be changed by anyone) that is structured in a similar way (I will use JSON to show an example):
	"key_1": "value_1",
	"key_2": "value_2",
	"object_1": {
		"object_1_key_1": "object_1_value_1",
		"object_1_key_2": "object_1_value_2",
		"object_1_key_2": "object_1_value_3",  

Open in new window

What would be the best Java data structure to obtain such result?

I thought a HashMap could've been a good start but then if I use:
private HashMap<String, String> myHash;

I am then forced to just use strings...

Can you please suggest a solution?

Thanks for your time and patience.
Suggestions for an appropriate way to retrieve a running Java programme into its state prior to such things as sockets and streams being opened, and threads run, variables set etc ?
I study a Java code and what the meaning of  "<T extends Shape> void printValidColors()" ?  Why does the data type appear as "<T extends Shape> " ?  For calling this method, do I always need to provide the format like "ShapeDriver.<Rectangle>printValidColors();" ?

public class ShapeDriver {

    public static void main(String args[]) {
        System.out.println("Valid Shape colors:-");

        System.out.println("Valid Rectangle colors:-");

        System.out.println("Valid Circle colors:-");

private static <T extends Shape> void printValidColors() {
        final int nthWrapEvery = 5;
        for (int i = 0; i < T.getNumOfValidColors(); i++) {
            System.out.print(T.getValidColor(i) + " ");
            if ((i + 1) % nthWrapEvery == 0) {

Open in new window

I need to check with you how to OR two Booleans please.

They need to be Booleans as they’ll be exchanged over a Socket. But they can be booleans locally of course. What’s the suggested best approach?
vec = new Vector<String>(fArr.length); // Vector<String> vec declared earlier.
            for(File fi : fArr){vec.add(fi.getName());}
            for(Object s : vec.toArray()){System.out.println((String)s);} // this prints the filenames to the console
            System.out.println("Files length is  "+fArr.length);// prints whatever length the array is
            System.out.print("vec is "); 
            System.out.println(vec==null); // prints TRUE !!

Open in new window

When displaying the contents of the credential file, I'm trying to apply each column of data to a variable. For example:

a = griffen.keyes

b = 108....

c = alphabet soup

d = zookeeper

The "c " variable it's not working correctly. Java is seeing this as two values despite the "".

How do I fix that?

Attached is a screenshot that I am reading from.
Below is my code so far.

package openCredFile;
import java.util.*;

public class TestingRandomMethods {
   public static void main(String[] args)throws IOException{
       TestingRandomMethods T = new TestingRandomMethods();  
       T.readFile(); //The main method calls these methods and executes them. It's the readFile method that prints the info.
    Scanner CredData; //Putting this outside of the method makes it available to all methods?
    public  void openFile() throws IOException {    //I had an error until I added "throws IOException" when trying to open the file.
        CredData = new Scanner(new File("credentials.txt")); //Opens the file.
        catch(Exception e){
            System.out.println("Could not find file.");
    public void readFile(){
        while(CredData.hasNext()){ //will loop until it reaches the end of the file. hasNext means to read the entire file.
            String a =;

I'm trying to read and output the contents of a file called credentials.txt. The code is below and attached is the error I'm getting.

package testingrandommethods;
import java.util.Scanner;

public class TestingRandomMethods {

    public static void main(String[] args) throws IOException {    //I had an error until I added "throws IOException" when trying to open the file.
        FileInputStream fileByteStream = null;
        Scanner credFile = null;
        String credData = "";

        //Attempt to open file
        fileByteStream = new FileInputStream("credentials.txt");
        credFile = new Scanner(fileByteStream); //credFile now contains what's in credentials.txt.
        System.out.println("Reading and printing data.");
        credData =; //credData now contains what's in credentials.txt as well. It allows me to read through the file.
        while (credData.charAt(0)){
            credData =;
        //Close the file
        System.out.println("Closing the credential.txt file.");


I am trying startup, however, i keep getting the following errors.

the domain controller service is up without issues, I can login http://<dc_ip>:9990

JBOSS: EAP 6.4 update 21

[jboss@domainController bin]$ ./
Exception in thread "Thread-2" java.lang.RuntimeException: broken pipe
      at org.jboss.aesh.console.reader.ConsoleInputSession$
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /]
[jboss@domainController bin]$

anyone can help? much appreciated

I have a java app, which acts as an oracle client/bridge between a mobile app ( data visualisation) and oracle database. The java app is capable to multithread if more than one request is made at a time.
No issues here, all works fine. The aim was to refrain from plugin mobile devices to the db.
Apart from the mobile app side, it's possible to run queries against the db on a scheduler i.e. every 5 mins and keep results in a buffer.

Anyway, In a production environment, my app was connected to a client database for a couple of weeks and suddenly the below error stopped the oracle form working causing a massive issue to the customer of mine.

ORA-01034: ORACLE not available ORA-27102: out of memory Linux-x86_64 Error: 12: Cannot allocate memory

Obviously, suspicion is that my product caused the Oracle problem. Apparently, oracle ran out of "accessible memory"  ( whatever that means - it wasn't techy guy who talked to me) my question to you is if running queries against DB can cause any memory issues?

As far as I know, a bad sql ( there wasn't any in this case) can cause long-running queries/sessions, which can consume a lot of CPU and indeed can slow oracle down...

what's your view on this, please ?
OWASP: Forgery and Phishing
LVL 13
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Can someone help me out to set a format (###,##0.00) to JavaFx editable Double TableColumn.
Here is my code so far

	taux.setCellFactory(TextFieldTableCell.<CoursChange, Double>forTableColumn(new DoubleStringConverter()));
		taux.setOnEditCommit(event -> {
            TablePosition<CoursChange, Double> pos = event.getTablePosition();
            double newVal = event.getNewValue();
            int row = pos.getRow();
            CoursChange xcours = event.getTableView().getItems().get(row);
            dataService.updateRecord(xcours.getId(), AppSettings.COMPANY_ID, newVal);

Open in new window

Thanks a lot
Hi Team,

I need an clarification in regard to creatiionn of  strings

for example when I create a string using string literals , i know it gets created in string constant pool .

Case 1 :
But when i  create it using the below code , does it get created in heap at runtime
String str="Hello";
String str1= str + "Welcome to Strings"; -- My question is does this string gets created in heap and a copy of the string is placed in scp by JVM.

The reason why iam asking this question is
I created one more string as below
String str2="Hello Welcome to Strings";  and then compared str1 and str2 using == it gave me false

The same thing I tried the other way
String str="Hello";
String str1= str + "Welcome to Strings";
String str2="Hello Welcome to Strings";

If (str1==str2)  -->it return true.

My question is based on the above scenarios , does it mean that when I create a string using non lietrals and non compile time constants it
creates the object in heap and stores a copy of the string in String constant pool.
Hi Team ,
Below is the code Iam using running jdbc application , Iam new to Java . Iam not getting the excpected output

folder NAme : jdbcprograms
in this folder I have ojdbc6.jar and file and class file.

import java.sql.*;

public class DBConnection
      public static void main(String [] args)
                  Connection conn = DriverManager.getConnection("jdbc:odbc:Oracle-Hr","HR","orcl");
            if (conn==null)
                  System.out.println("Connection not established");
                  System.out.println("Connection is  established");
            catch(SQLException e)
            catch(ClassNotFoundException e)      
            catch(Exception e)

When I run the code as below , I get the below output , but not getting the connection established output. Any help is really appreciated

D:\JdbcPrograms>java -jar ojdbc6.jar DBConnection
Oracle JDBC 4.0 compiled with JDK6

Expected Output
Class Name Output for Connection Class
Connection established.
Hi: I am using Java to amend a text file. There are 80 fields (csv) in the file so I have split into 80 string arrays.
However, one amendment requires me to subtract one array from another. It is the last amendment I need to do!
Does anybody know how to change a string array in java to a number?
I attach the csv file I am trying to amend, plus the java I have written so far. Don't laugh; I am just a novice at this stuff.
Line 166 in the java is where i have 'added' the two arrays  - String d4 = (x[62])+ (x[63]);
I need to subtract!
In selenium is it possible to know the type of the locator whether it is given in css or xpath or id or name or linktext etc..

the requirement is i get the locator in the form of a string and i have to know whether it is CSS or xpath

By selector = driver.findElement(By.cssSelector(locator));

if(selector == null){

  selector = driver.findElement(By.xpath(locator)); }

Open in new window

as the very first statement throws an exception if it is a different locator, is there an easy way that we can identify the type and handle and type of locator
I m new in Java and i need help with a question i have.
Protected Constructors can be accessed form subclasses from other packages too.
Can i create one object from this subclasses? And if yes is there any sample code ?
thank you in advance.






Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.