Try this code. Main class
package com.sree;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import com.sree.test.CreateFile;
public class Test {
public static void main(String[] args) throws SecurityException,
NoSuchMethodException, IllegalArgumentException,
InstantiationException, IllegalAccessException,
InvocationTargetException {
Constructor<CreateFileAction> action = CreateFileAction.class
.getConstructor(CreateFile.class);
CreateFile file = new CreateFile();
System.out.println(action.newInstance(file));
// System.out.println(action);
}
}
your dependent classes
package com.sree;
import com.sree.test.CreateFile;
public class CreateFileAction {
private CreateFile file_c;
public CreateFileAction() {
System.out.println(" constructor null");
}
public CreateFileAction(CreateFile file) {
System.out.println(" constructor not null");
this.file_c = file;
}
}
package com.sree.test;
public class CreateFile {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}