Unable to use a package org.apache.commons.lang.StringUtils
Asked Answered
U

3

9

I am new to Jdeveloper and I was writing a program which used text in between two strings. I stumbled upon StringUtils.substringBetween() function but when I compile the program it says it cannot find variable StringUtils and does not recognise org.apache.commons.lang.StringUtils package. Please do tell me where I am going wrong. One thing I thought was the package was missing from the libraries but since I am new I don't know how to install such a package or where to install for that matter. I am using jdev 10.1.3.5.0. The code I stumbled upon on the net is this:

import java.util.Date;

import org.apache.commons.lang.StringUtils;

public class NestedString {

    public static void main(String[] args) {

        String helloHtml = "<html>" + "<head>" + " <title>Hello World from Java</title>"
                + "<body>" + "Hello, today is: " + new Date() + "</body>" + "</html>";
        String title = StringUtils.substringBetween(helloHtml, "<title>", "</title>");
        String content = StringUtils.substringBetween(helloHtml, "<body>", "</body>");
        System.out.println("title = " + title);
        System.out.println("content = " + content);
    }
}
Upas answered 19/11, 2011 at 6:48 Comment(3)
I imagine that JDeveloper surely has a way to add libraries and jar files to your project's build path. You'll want to check the IDE's helpfile to see how to do this.Sikora
Got it.Just went to the project then project properties and added the jar file in the library.Thanks for putting me in the right direction.Upas
Cool, glad you've now got it working!Sikora
B
5

Download apache-lang common from apache jakarta sie:

http://commons.apache.org/lang/

After getting jar file please put this jar in your project's build path, if you are not able to find build path then go Jdeveloper help file and type "build path" and you will get all intrustion over there.

Boatwright answered 19/11, 2011 at 7:7 Comment(0)
R
0

Download commons-lang and throw it into your /WEB-INF/lib folder.

If its not a web application you have to check how you can add it to your build path with JDeveloper.

Roxannaroxanne answered 19/11, 2011 at 7:5 Comment(0)
P
-1

Add Apache Maven library. This will resolves the issue (project properties -> libraries and class patch -> add library).

Puttergill answered 18/8, 2016 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.