Unable to find JDK

MatForsbergMatForsberg USUniversity ✭✭
edited June 2015 in Xamarin University

I am trying to write a Xamarin.UITest test. Upon executing it I get this error:

An exception of type 'System.Exception' occurred in Xamarin.UITest.dll but was not handled in user code
Additional information: Java Development Kit (JDK) not found. Please make sure that it is installed and if it's still not located, please set the JAVA_HOME environment variable to point to the directory.
Searched locations:Windows Registry
[ Source: JAVA_HOME ]

On this line:
return ConfigureApp.Android.ApkFile("C:/Users/mforsberg/Documents/Visual Studio 2013/Projects/PhoneWords/PhoneWords/bin/Debug/PhoneWords.PhoneWords-Signed.apk").StartApp();

My code consists of :

public class AppInitializer
    {
        public static IApp StartApp(Platform platform)
        {
            if (platform == Platform.Android)
            {
                return ConfigureApp
                    .Android
                    .ApkFile("C:/Users/mforsberg/Documents/Visual Studio 2013/Projects/PhoneWords/PhoneWords/bin/Debug/PhoneWords.PhoneWords-Signed.apk")
                    .StartApp();
            }

            return ConfigureApp
                .iOS
                .StartApp();
        }
    }

[Binding]
    public class SpecFlowFeature1Steps
    {
        readonly IApp app = AppInitializer.StartApp(Platform.Android);

        [Given(@"I have entered ""(.*)"" into the PhoneWordEditText")]
        public void GivenIHaveEnteredIntoThePhoneWordEditText(string p0)
        {
            app.WaitForElement(c => c.Marked("PhoneWordEditText"));
            app.EnterText(c => c.Marked("PhoneWordEditText"), p0);
            p0.Should().Contain("a");
        }

        [When(@"I press translate")]
        public void WhenIPressTranslate()
        {
            ScenarioContext.Current.Pending();
        }

        [Then(@"the result should be ""Call (.*)"" on the CallButton\.Text")]
        public void ThenTheResultShouldBeOnTheCallButton_Text(string p0)
        {
            ScenarioContext.Current.Pending();
        }
    }

I am using FluentAssertion, SpecFlow and XamarinUITest

I have an environment variable JAVA_HOME = C:\Program Files\Java\jdk1.7.0_67
My Path variable starts out: .;%JAVA_HOME/bin%;%JAVA_HOME%/jre/bin;

I have tried different variations with the path including taking the contents of JAVA_HOME and putting it directly in the path variable.

Tagged:

Best Answer

Answers

  • MarkSmith.8123MarkSmith.8123 USXamarin Team, University, XamUProfessors Xamurai

    Hi @MatForsberg

    JAVA_HOME is the environment variable it wants, can you make sure the folder exists, and is spelled correctly just to be sure it's all setup? It won't use the path to find it. Also, make sure the variable is in the system section, not user section. Are you using an IDE to run the tests, or NUnit on the command line?

    mark

  • MatForsbergMatForsberg USUniversity ✭✭

    C:\Program Files\Java\jdk1.7.0_67\bin exists. I have copied and pasted the path from explorer to my environment variable. It is in the system section. I am running these tests using visual studio 2013.

  • MatForsbergMatForsberg USUniversity ✭✭

    Solved. I installed another jdk, changed the JAVA_HOME reference and restarted. that fixed that issue

Sign In or Register to comment.