0

I am using Eclipse Version: 2019-06 (4.12.0). For my Rest Assured project, I have downloaded and added the JAR files from the path https://github.com/rest-assured/rest-assured/wiki/Downloads. For the keyword "RestAssured" Eclipse should suggest to import the package which is missing. Can anyone please help me in fixing this?

*package com.RestAssured; public class Basic {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    
    RestAssured.
}

}*

[Java Build Path][1] [1]: https://i.stack.imgur.com/sl0Dr.png

[Eclipse UI][2] [2]: https://i.stack.imgur.com/62e5v.png

  • Maybe you have a `module-info.java` file in the default package and missed to add the corresponding requires statement. If this is not the cause, show that the project's _Java Build Path_ is correct and give an code example how to reproduce your issue (to make clear where and when you expect Eclipse to suggest to import that package). – howlger Sep 02 '20 at 07:13
  • @howlger While creating a new Java Project, it asked me to create module-info.java for which I selected "Don't create". Is it correct or I should have created module-info.java? Answering to your second question, while adding External Jar files, I could see 2 options, Modulepath and Classpath. I tried adding Jar files in either of them. Answering to your 3rd question, I didn't write any code, I just wrote "RestAssured" and did ctrl+space for which Eclipse should be suggesting me to import package but it's not happening. Please let me know if I can help you with any other information. – AnkitKumarSahoo Sep 03 '20 at 18:05
  • It's easier not to have a `module-info.java` and put everything on the classpath (or learn about [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System)). If you write `RestAssured` outside of a class, you will not get any code completion proposals since it cannot be use at this location. So please give a code example with a marker where your cursor is and show your _Java Build Path_. – howlger Sep 03 '20 at 22:15
  • @howlger I didn't have module-info.java and put everything on the classpath but no luck. RestAssured lies inside the class. I have added the code in the description of my question and added 2 screenshots as well that shows the Eclipse UI and Java Build Path. – AnkitKumarSahoo Sep 04 '20 at 06:43
  • Your Eclipse is pretty old. It might be that the class `RestAssured` has been compiled with a Java version that your outdated Eclipse cannot read. – howlger Sep 04 '20 at 08:05
  • @howlger Removed the existing one and downloaded the latest Eclipse Version: 2020-06 (4.16.0) Build id: 20200615-1200, still seeing the same error. – AnkitKumarSahoo Sep 04 '20 at 09:33
  • Please show that your Java Build Path is correct by showing the `RestAssured` class in the _Package Explorer_ below the _Referenced Libraries_ node and opened in an editor. – howlger Sep 04 '20 at 09:40
  • 1
    my apology, I missed to add RestAssured Jar itself. Now, It's working fine. Thank you @howlger – AnkitKumarSahoo Sep 04 '20 at 18:48

1 Answers1

0

Try deleting the existing java plugin, if u are using java version above 1.8 and install both jdk and jre (1.8) and add those in the system External variable and check when creating a new project in eclipse, verify the execution environment is in JavaSE-1.8. Try this

Damini Suthar
  • 1,470
  • 2
  • 14
  • 43