Question

I am going through the Struts2 tutorial at http://struts.apache.org/release/2.2.x/docs/hello-world-using-struts-2.html

They have a file HelloWorld.java that defines a class HelloWorldAction and the compiler (as run from ant) complains:

[javac] HelloWorld.java:6: class HelloWorldAction is public, should be declared in a file named HelloWorldAction.java

Obviously I can fix this, but is the tutorial really this wrong, or is there some configuration setting that I am missing? I already fixed this once with the tutorial having class MessageStore defined in Message.java and I'm wondering if I'm missing something.

Was it helpful?

Solution

The caption says

Step 2 - Create The Action Class HelloWorldAction.java

So just rename the file that's probably the typo. There are no such config. Java always wants you to name files accordingly.

OTHER TIPS

Yes, it is wrong. You need to name it HelloWorldAction.java

enter image description here

public class Foo

must always be named Foo.java no matter what framework you are using or javac will complain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top