0

AddBookAction.java

    import com.opensymphony.xwork2.ActionSupport;
    public class AddBookAction extends ActionSupport {
    private static final long serialVersionUID = 1L;
    private String id, name,aname,badd;
    private String msg = "";
    int ok = 0;


    public String execute() throws Exception {
    Main main = new Main();
    try {
ok = main.AddBook(id,name);
if (ok > 0) {
msg = "Registration Successfull";
} else {
msg = "error";
}
} catch (Exception e) {
e.printStackTrace();
}
return "SUCCESS";
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAname() {
return aname;
}
public void setAname(String aname) {
this.aname = aname;
}
public String getBadd() {
return badd;
}
public void setBadd(String badd) {
this.badd = badd;
}
}

Error:

C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\Library\WEB-INF\classes>javac -cp ..\lib\xwork.jar AddBookAction.java
AddBookAction.java:1: error: package com.opensymphony.xwork2 does not exist
import com.opensymphony.xwork2.ActionSupport;
                              ^
AddBookAction.java:3: error: cannot find symbol
public class AddBookAction extends ActionSupport

jars in my lib

enter image description here

Path added in system variable

enter image description here

xwork package added in my lib folder, system variable[class path], but while compiling I'm getting the error stating that the package isn't added on my class path. Doing the project only by notepad file not in the eclipse or any other IDE. This is my task need to do. Tried so many ways but unable to fix.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Nov 23 '22 at 08:50

2 Answers2

0

ActionSupport is in a different library. To get the current implementation of ActionSupport,

import com.opensymphony.xwork2.ActionSupport;

My team is on Apache Struts 2.5.30, and the distribution .jar includes the class you seek. You can also look at Struts 6.0.3.

Docs: https://struts.apache.org/maven/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html

David Gorsline
  • 4,933
  • 12
  • 31
  • 36
0

Since you have added a library xwork.jar on the classpath manually you can't run your project because this library is removed from the lib set.

For more details how to resolve conflict between packages xwork and xwork-core see this answer Conflicts in xwork and xwork-core.

Each distro of Struts2 supplied with the corresponding set of libraries in the lib folder that are compatible with the version of distro. If you use maven to resolve and fetch the dependencies you should consider the artifact struts2-core.

Roman C
  • 49,761
  • 33
  • 66
  • 176