We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Foreach not applicable to expression type for (Section srcSection : src)

We are using three aspose.word jars in production and it is from the very beginning. I don't exactly the need for using 3 jars.


Implementation-Version: (same version in all three jars)

java version is 1.6
Environment is Windows, Unix

Java Code :

Document doc=new Document(TEMPLATE_PATH);
Document srcDoc = new Document(TEMPLATE_PATH2);

for (Section srcSection : srcDoc.getSections()) {
Node dstSection = doc.importNode(srcSection, true, ImportFormatMode.KEEP_SOURCE_FORMATTING);

When we compile project we are getting compilation error
Even we are using Iterator for iterating SectionCollection also we are getting compilation error.

[javac] /home/wasadmin/release_BV_31012017/02.RSM/01.Working/04.BuildCR1/RSMBusiness/src/com/bvonesource/rsm/dao/dfc/BasicSummaryDAOImpl.java:1945: foreach not applicable to expression type
[javac] for (Section srcSection : src) {

when we remove aspose14jdk and aspose15jdk jar from project then it compile successfully.

Please suggest the deletion of these two jars is safe or not as it is referring only aspose.wordsjdk16 jar or do you have any alternate for iterating by keeping all the three version.


Thanks for your inquiry. There is no need to include three JAR files of same Aspose.Words version.

The latest version of Aspose.Words for Java 17.2.0 comes with only one JAR i.e. “aspose-words-17.2.0-jdk16.jar”. So, we suggest you please upgrade to the latest version of Aspose.Words for Java 17.2.0 and see how it goes on your end. Hope, this helps. You can download it from the following link:

Best regards,