The JRE_HOME environment variable is not defined correctly

Source: Internet
Author: User
Tags garbage collection goto jprofiler

Problem ①,the jre_home environment variable is not defined correctly

1, according to the boot information, determine the startup files



"1" Start Startup_jprofiler.bat file first

"2" Restart Setclasspath.bat (this file relates to Jre_home/jdk_home's environment)

So modify the following: (Add the Red section, respectively, where the JDK and JRE are installed)


REM---------------------------------------------------------------------------
REM Set Java_home or Jre_home if not already set, ensure any provided settings
REM is valid and consistent with the selected start-up options and set up the
REM endorsed directory.
REM---------------------------------------------------------------------------


Set Java_home=e:\javajdk7
Set Jre_home=e:\javajdk7\javajre7


REM Make sure prerequisite environment variables is set


REM in debug mode We need a real JDK (java_home)
If ""%1 "" = = "" Debug "" Goto Needjavahome


REM Otherwise either JRE or JDK is fine
If not "%jre_home%" = = "goto gotjrehome
If not "%java_home%" = = "goto gotjavahome
Echo neither the Java_home nor the JRE_HOME environment variable is defined
Echo at least one of these environment variable are needed to run this program
Goto exit


: Needjavahome
REM Check If we have a usable JDK
If "%java_home%" = = "goto nojavahome
If not exist "%java_home%\bin\java.exe" goto nojavahome
If not exist "%java_home%\bin\javaw.exe" goto nojavahome
If not exist "%java_home%\bin\jdb.exe" goto nojavahome
If not exist "%java_home%\bin\javac.exe" goto nojavahome
Set "Jre_home=%java_home%"
Goto Okjava


: Nojavahome
echo the JAVA_HOME environment variable is not defined correctly.
Echo It is needed to run the This program in debug mode.
Echo Nb:java_home should point-a JDK not a JRE.
Goto exit


: Gotjavahome
REM No JRE Given, use Java_home as Jre_home
Set "Jre_home=%java_home%"


: Gotjrehome
REM Check If we have a usable JRE
If not exist "%jre_home%\bin\java.exe" goto nojrehome
If not exist "%jre_home%\bin\javaw.exe" goto nojrehome
Goto Okjava


: Nojrehome
REM Needed at least a JRE
echo the JRE_HOME environment variable is not defined correctly
echo this environment variable are needed to run
Goto exit


: Okjava
rem Don ' t override the endorsed Dir if the user has set it previously
If not "%java_endorsed_dirs%" = = "goto Gotendorseddir
REM Set the Default-djava.endorsed.dirs argument
Set "Java_endorsed_dirs=%catalina_home%\endorsed"
: Gotendorseddir


rem Don ' t override _runjava if the user has set it previously
If not "%_runjava%" = = "goto Gotrunjava
REM Set standard command for invoking Java.
REM Also note the quoting as jre_home may contain spaces.
Set _runjava= "%jre_home%\bin\java.exe"
: Gotrunjava


rem Don ' t override _runjdb if the user has set it previously
REM Also note the quoting as java_home may contain spaces.
If not "%_runjdb%" = = "goto gotrunjdb
Set _runjdb= "%java_home%\bin\jdb.exe"
: Gotrunjdb


Goto END


: Exit
Exit/b 1


: End
Exit/b 0





Configuring Test Cases

1. Click D:/jprofiler5/bin/jprofiler.exe

2. Execution Menu Sessionàintegration wizardsànew serverintegration

Choose whether to test locally or remotely:

Select the script file that Tomcat runs:

Select the type of virtual machine:

Select the monitoring port:

With the default, you can

Select whether the Web container runs with Jprofiler:

By default you can

Configuration tips:

You should read it carefully when you are "remote control".

Then choose Start now to run.

Click "OK", we can see another small window came out:

The Jprofiler window is:

So we can monitor it.

(v) Start testing

1. In the IE Address bar, enter: http://localhost/test/init1.jsp, execute once, we can see in memory view the Cn.test.TestBean object was created 10,000 times:

2. Mark the current state, then execute init1.jsp and, init2.jsp can let us find which classes are not released after the call (very important ...). )

See which classes have changed:

The red becomes the object of change and its number.

I have just executed 4 init1.jsp and 1 init2.jsp, which produced 50,000 Testbean objects, just like the one shown in the illustration.

3. After a while, press the F4 key for garbage collection. However, after the collection is complete, these objects still exist, indicating that references to this class have not been released in some places.

4. Find out where the Testbean classes are used and do not release them

Right-click on the Cn.test.TestBean object to select "Take Heap Snapshot for Selection" and observe its heap

Next:

Click "OK":

Right-click in the class and select "Use Selected Objects" in the menu that appears:

The following window appears:

Select "Allocations" and click "OK", and then we'll get the results.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.