Automation QA Testing Course Content

Showing posts with label Eclipse IDE. Show all posts
Showing posts with label Eclipse IDE. Show all posts

Eclipse – java.lang.OutOfMemoryError: Java heap space

In Eclipse IDE, if your program is consuming a lot of memory (loading big data)  then it will throw java.lang.OutOfMemoryError: Java heap space issue.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.<init>(HashMap.java:209)

at java.util.LinkedHashMap.<init>(LinkedHashMap.java:181)

1. Solution – VM arguments

On Eclipse menu, clicks Run -> Run Configurations.., select the Java application you want to run, clicks on the Arguments tab, update the VM arguments with the following options
-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size

For example, -Xms512M -Xmx1024M


If you still face the java.lang.outofmemoryerror gc overhead limit exceeded eclipse

Steps to Solve the above issue in Eclipse
On Eclipse menu, clicks Run -> Run Configurations.., select the Java application you want to run, clicks on the Arguments tab, update the VM arguments with the following options

-Xms6144M -Xmx12288M 
-XX:+UseG1GC
-XX:+UseStringDeduplication

How to Save Eclipse console logs in external log file

While debugging an application in Eclipse you might have noticed that important logs are lost from the console as its buffer size is reached. One of the way you can get them is by redirecting them to an external text file,

How to redirect Eclipse console logs to external file

  1. Go-to Eclipse Menu : Run -> Run Configuration.
  2. Go-to Common tab.
  3. Under Standard Input and Output : Select Output file checkbox, enter log file name and path where you want logs to be redirected.
  4. Apply changes and run your application.
  5. You would notice that console logs are redirected to the external file as stated in the first console line : [Console output redirected to file:/Documents/eclipseLogs.log]

Create New Java Class for particular package in Java Project

1)Expand the Java Project

2)Right click on src folder-->new -->package-->click on Package

3)  Enter package name-->click on finish button

4)Right click on package name-->New -->class-->click on class
5)Enter class name & Check the main() checkbox-->click on Finish button

6) Java class will show like below

7)Run the Java Program in Eclipse
Click menu Run > Run (or press Ctrl + F11), Eclipse will execute the application and show the output in the Console view:

Create a new Java Project in Eclipse IDE

1)Launch the Eclipse IDE
2)Expand File menu---->new -->Project

3)Type Java in select wizard textbox-->select the java project -->click Next button


4)Enter Project Name -->Click on Finish button

5)Project will be shown in Project explorer in left panel

Download Eclipse IDE & Launch Eclipse IDE

Follow the below steps To Download Eclipse IDE

Download latest version Java 14:
https://www.oracle.com/java/technologies/javase-jdk14-downloads.html

1)Type Eclipse IDE in google search editbox & Click on Eclipse Downloads | The Eclipse Foundation



2)Click on Download Packages link in Eclipse home page
3)Select the Eclipse 2019-09 (4.13) under MORE DOWNLOADS section
4)Click on Windows -64 link against Eclipse IDE for Java Developers

5)Click on Download button

6)Download process in load
7)Place the downloaded eclipse ZIP file in C drive folder -eclipse64 and Then UNZIP the zip file[or extract the zip file]

8)Go into the unzipped folder:eclipse-java-2019-09-R-win32-x86_64-->eclipse--->click on purple eclipse icon inside the eclipse folder

9)Eclipse IDE Launcher window will open -->select the Workspace C:\eclipse-workspace
10)Welcome window will open & create Java Project