Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How does Java work in Talend?

I am trying to learn Java within Talend and seems to be running into errors. The code works fine here:
http://ideone.com/ydUNgo
import java.util*;
import java.lang.*;
import java.io.*;
class Stringdemo
{
public static void main (String [] args) throws java.lang.Exception
{
String str1 = "Jake Wagner";
String str2 = "Tony Ruggeri";
String str3 = "tony ruGGeri";

// checking for equality
boolean retval1 = str2.equals(str1);
boolean retval2 = str2.equalsIgnoreCase(str3);

// prints the return value
System.out.println("str2 is equal to str1 = " + retval1);
System.out.println("str2 is equal to str3 = " + retval2);

}
}

Error in Talend using tJava:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
Syntax error on token "import", assert expected
java.util cannot be resolved to a type
Syntax error on tokens, delete these tokens
java.lang.java cannot be resolved to a type
Syntax error on tokens, delete these tokens
Syntax error on token "*", class expected
The method main cannot be declared static; static methods can only be declared in a static or top level type
Any assistance would be appreciated.
Thanks in Advance,
CM
Labels (3)
3 Replies
TRF
Champion II
Champion II

Hi,
Move import to Advanced setting tab dedicated section.
If you need to declare classes and methods, use routine. In tJava* components, just use plain Java.
Regards,
TRF
Haresh
Contributor
Contributor

How to add classes and methods to the routine? please assist

root
Creator II
Creator II

Can you be a bit more specific on what you are trying to achieve? Simply importing your predefined classes can happen by going to "Advanced Settings" tab of the tJava component and adding them. If its a non-standard library, you may want to use tLibraryLoad component in pre-job or main job and then register the imports in the "Advanced Settings" tab.