The jar text file runs on cmd windows error. How can this be fixed?

So, I get this error when I try to run a very simple text banner in Windows cmd:

 Exception in thread "main" java.lang.IllegalAccessException: Class
 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader can not access
 a member of class me.Puffinlump.ItemDivider.Minecraftitemsdivider
 with modifiers "public static"
         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
         at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261)
         at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253)
         at java.lang.reflect.Method.invoke(Method.java:599)
         at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)

      

It works fine in Eclipse, but not with anything else. I don't know how to create a console for it that allows input and output, or any console at all. Basically I am unable to create a console.

Here is my code:

package me.Puffinlump.ItemDivider;

import java.util.Scanner;

class Minecraftitemsdivider {
    public static void main(String args[]) {
        Scanner keyboard = new Scanner(System.in);
        //Values for the script
        String Itemname;
        String Thingname;
        int Iammount;
        int things;
        int Itemsperthings;

        //Question
        System.out.print("What is the name of your item? What type of things are you giving them to e.g. Player? How many are you giving? How many things are you dividing it among?");
        //The start of the input values.
        Itemname = keyboard.next();
        Thingname = keyboard.next();
        Iammount = keyboard.nextInt();
        things = keyboard.nextInt();
        //The end of the input values.

        //Math
        Itemsperthings = Iammount / things;

        //Printer
        System.out.print("Each ");
        System.out.print(Thingname);
        System.out.print(" gets ");
        System.out.print(Itemsperthings);
        System.out.print(" ");
        System.out.print(Itemname);
        System.out.print("s.");

        //Ending process
        keyboard.close();
    }


}

      

+3


source to share


1 answer


Your class should be public

, so change

class Minecraftitemsdivider

      



to

public class Minecraftitemsdivider

      

+1


source







All Articles