Hello all, I'm using the version 6 of Eclipse JAVA development. The code below is very basic, but I'm getting warnings which is probably preventing me from running the application. Any ideas? Basically what I'm designing is a program which would input the radius and therefore it would display the circumference, area, and diameter.

Just updated the code below..

package java.lang;

import java.util.Scanner;

public class Circle 
{
	public static void main(String[] args)
	{
		//create input dialog
		Scanner input = new Scanner(System.in);
		//initializing variables
		int radius = 0, diameter;
		double circumference, area;
		//creating formulas
		diameter = 2*radius;
		circumference = Math.PI*diameter;
		area = Math.PI*radius*radius;
		//creating input/displays
		System.out.print("\nThe radius is: ");
		radius = input.nextInt();
	}

}

These are my errors...
java.lang.SecurityException: Prohibited package name: java.lang
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

I just decided to create a new code instead and I'm still getting the same errors, im not even sure what's going on...

import javax.swing.JOptionPane;

public class Circle 
{
	public static void main(String[] args)
	{
		String radius;
		int radius1;
		double circumference, area, diameter;
		
		radius = JOption.Pane.showInputDialog("Enter the radius");
		radius1 = Integer.parseInt(radius);
		//creating formulas
		diameter = 2*radius;
		circumference = Math.PI*diameter;
		area = Math.PI*radius*radius;
		
		JOptionPane.showMessageDialog("The diameter is" + diameter);
}
}

No offense intended, but if you are using Eclipse IDE, it would tell you very explicitly where your errors are and how to fix them. You just had a few minor typos. Here's the fixed code:

import javax.swing.JOptionPane;

public class Circle
{
	public static void main(String[] args)
	{
		String radius;
		int radius1;
		double circumference, area, diameter;
		
		radius = JOptionPane.showInputDialog("Enter the radius");
		radius1 = Integer.parseInt(radius);
		//creating formulas
		diameter = 2*radius1;
		circumference = Math.PI*diameter;
		area = Math.PI*radius1*radius1;
		
		JOptionPane.showMessageDialog(null, "The diameter is" + diameter);
	}
}

Per your response, I ran the code and still received errors:...

java.lang.SecurityException: Prohibited package name: java.lang
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Don't define your class to be in java.lang package.

DaniWebOS,

Going from your first piece of code, you needed to get the radius first before anything else.

All the calculations were otherwise useless as you were multiplying by 0. Then it would have been fine to begin with.

I hope this helps.

Regards,
Cleo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.