Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
MKAPOOR1596038160
Contributor II
Contributor II

tJavaRow not working as expected

I am using tJavaRow in TOS where in i am using following code to sort string: "gnbsx00061 gnbsx00063 gnx10326"

In tJAVARow : After sorting it results in "gnx10326 gnbsx00061 gnbsx00063"

String [] licsvr = input_row.lic_server_name.split(" ");

java.util.Arrays.sort(licsvr);

output_row.lic_server_name = java.util.Arrays.toString(licsvr).replace(",", "").replace("[", "").replace("]", "");

While if i run the same following java code in test.java file on standalone linux machine

import java.util.*;

public class test {

public static void main(String[] args) {

String p = "gnx10326 gnbsx00061 gnbsx00063";

String [] licsvr = p.split(" ");

java.util.Arrays.sort(licsvr);

System.out.println(java.util.Arrays.toString(licsvr).replace(",", "").replace("[", "").replace("]", ""));

}

}

running it results in :

java test

gnbsx00061 gnbsx00063 gnx10326

The linux java program output is what i am expecting. please help?

Labels (3)
6 Replies
root
Creator II
Creator II

Probably try it in tJava component instead of the tJavaRow and do the operations? Thanks

Jesperrekuh
Specialist
Specialist

System.out.println( input_row.lic_server_name ) ;

To make sure it contains values?

 

 

MKAPOOR1596038160
Contributor II
Contributor II
Author

tJavaRow in my design a part of flow and i transform one field using tJavaRow. How can i use tJava in this scenario?

MKAPOOR1596038160
Contributor II
Contributor II
Author

Another point to highlight is that tJavaRow is doing sorting correctly in cases like

"gnbsx00016 gnbsx00013 gnbsx00014" gets transformed correctly with tJavaRow to "gnbsx00013 gnbsx00014 gnbsx00016".

 

But in case of gnbsx00063 gnbsx00061 gnx10326, it is unable to sort correctly by transforming it to "gnx10326 gnbsx00061 gnbsx00063" .

 

The expectation is to sort them in order of alphabetically first then numerically second but it is not happening with tJavaRow.

 

 

pakapi_
Creator
Creator

Hi MKAPOOR1596038160,

 

you are 100% sure that your tjavaRow sorting result is gnx10326 gnbsx00061 gnbsx00063 ?

I've tested your both codes and got the same result: gnbsx00061 gnbsx00063 gnx10326.

You are using the same method java.util.Arrays.sort so for me - it's not possible to get diffrent results.

 

My tJava version:

 

String p = "gnx10326 gnbsx00061 gnbsx00063";

String[] licsvr = p.split(" ");

 

java.util.Arrays.sort(licsvr);

 

System.out.println(java.util.Arrays.toString(licsvr).replace(",", "").replace("[", "").replace("]", ""));

 

tJavaRow version:

input: gnx10326 gnbsx00061 gnbsx00063

String [] licsvr = input_row.lic_server_name.split(" ");

 

java.util.Arrays.sort(licsvr);

 

output_row.lic_server_name = java.util.Arrays.toString(licsvr).replace(",", "").replace("[", "").replace("]", "");

 

MKAPOOR1596038160
Contributor II
Contributor II
Author

I got this issue solved after replacing openjdk with oracle java and the version to 1.8.0.05.

 

Thanks a lot for your help.