Skip to Main Content


User_AYF65Oct 6 2018 — edited Oct 7 2018

I am getting executor-snippets\run.xml:48 error. I have a main class "JavaJUNITExample8_2". I have created a PrintGrades2 class in it.

public class PrintGrades2 {


    static char getGrade(int score) {

        char grade='\0';

        if (score >= 90)


            else if(score>=80)

                grade = 'B';


            and so on


            return grade;



And i created a test class using Tools->create/update test.

import org.junit.After;

import org.junit.AfterClass;

import org.junit.Before;

import org.junit.BeforeClass;

import org.junit.Test;

import static org.junit.Assert.*;



* @author HP


public class PrintGrades2Test {


    public PrintGrades2Test() {




    public static void setUpClass() {




    public static void tearDownClass() {




    public void setUp() {




    public void tearDown() {



     * Test of getGrade method, of class PrintGrades2.



    public void testGetGrade() {



        int score = 0;

        char expResult = ' ';




    and so on







and my main method of main class is:

package javajunitexample8_2;

import org.junit.runner.JUnitCore;

import org.junit.runner.Result;

import org.junit.runner.notification.Failure;



* @author HP


public class JavaJUNITExample8_2 {


     * @param args the command line arguments


    public static void main(String[] args) {

        // TODO code application logic here

       Result result = JUnitCore.runClasses(PrintGrades2Test.class); //error on this line

for (Failure failure : result.getFailures()) {








I am getting following error message:


Cancelled by user.

BUILD FAILED (total time: 3 seconds)

And code of run.xml is:

<?xml version="1.0" encoding="UTF-8"?>



Copyright 2010 Oracle and/or its affiliates. All rights reserved.

Oracle and Java are registered trademarks of Oracle and/or its affiliates.

Other names may be trademarks of their respective owners.

The contents of this file are subject to the terms of either the GNU

General Public License Version 2 only ("GPL") or the Common

Development and Distribution License("CDDL") (collectively, the

"License"). You may not use this file except in compliance with the

License. You can obtain a copy of the License at

or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the

specific language governing permissions and limitations under the

License.  When distributing the software, include this License Header

Notice in each file and include the License file at

nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this

particular file as subject to the "Classpath" exception as provided

by Oracle in the GPL Version 2 section of the License file that

accompanied this code. If applicable, add the following below the

License Header, with the fields enclosed by brackets [] replaced by

your own identifying information:

"Portions Copyrighted [year] [name of copyright owner]"


The Original Software is NetBeans. The Initial Developer of the Original

Software is Sun Microsystems, Inc. Portions Copyright 2008 Sun

Microsystems, Inc. All Rights Reserved.

If you wish your version of this file to be governed by only the CDDL

or only the GPL Version 2, indicate your decision by adding

"[Contributor] elects to include this software in this distribution

under the [CDDL or GPL Version 2] license." If you do not indicate a

single choice of license, a recipient has the option to distribute

your version of this file under either the CDDL, the GPL Version 2 or

to extend the choice of license to its licensees as provided above.

However, if you add GPL Version 2 code and therefore, elected the GPL

Version 2 license, then the option applies only if the new code is

made subject to such option by the copyright holder.


<project name="{0} (run)" default="run" basedir=".">

    <target name="run">       

        <translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />

        <property name="run.jvmargs" value="" />

        <property name="work.dir" value="${basedir}"/>

        <property name="application.args" value="" />

        <property name="java.failonerror" value="true"/>

        <java classpath="${classpath-translated}" classname="${classname}" dir="${work.dir}" jvm="${}" fork="true" failonerror="${java.failonerror}">

            <jvmarg value="-Dfile.encoding=${encoding}"/>

            <redirector inputencoding="${encoding}" outputencoding="${encoding}" errorencoding="${encoding}"/>

            <jvmarg line="${run.jvmargs}" />

            <arg line="${application.args}" />


                <propertyref prefix="run-sys-prop."/>

                <mapper from="run-sys-prop.*" to="*" type="glob"/>





Some body please guide me.


Post Details
Added on Oct 6 2018