I keep getting an error every time saying there is no main class ...
Loan
public class Loan implements LoanConstant{
public static int loanNumber;
public static String lastName;
public static int loanAmount;
public static int interestRate;
public static int term;
public int primRate;
In the following piece of code Iam trying to display the the loan amounts of the various loan objects located in a binary file. Iam trying to do his using getLoanAmount() in the loan class. the program is compiling but nothing is showing up on he console.
Program import java.io.*; public class Exercise19_06 { public static void main(String[] args) throws ClassNotFoundException, IOException { ObjectOutputStream output = new ObjectOutputStream( new FileOutputStream("loan.dat"));
I'm trying to fill a List<String>, named overlappedGrid, from another List<String>, named listGrid. I'm facing an exception:Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - unexpected type
required: variable found: value at arab2004_d.ProcessingLayer.printShape(Arab2004_D.j ava:101) at arab2004_d.Arab2004_D.main(Arab2004_D.java:30)
Java Result: 1
Here is my source code (the exception line is commented "here is the exception"):
I understand how to write a child object. I know what can access what and the order of execution of each statement, including fields, initialization blocks, and constructors. I know what will be inherited by the child and how private fields and methods are not inherited. I also know that private fields and methods in Parent are still accessible indirectly through constructors, and non-private methods. I know how to use super() and this() with or without parameters. I know when super() will be automatically inserted by the compiler and how the Object class will always be the ultimate parent class. However, I have not been able to find an explanation of exactly (or even approximately) how all this is actually put together into an actual object in memory.
For instance, if Parent.field is private and Parent.fieldGetter() is public then Child inherits fieldGetter() and can call it directly as if it is a member of Child. In fact other classes can call Child.fieldGetter() with no clue that it is not an actual member of Child. But, if fieldGetter() is now part of Child and Parent was never actually instantiated, then how is Parent.field available for Child.fieldGetter() to read? In fact, how does Parent.field exist at all? Where is it stored? (OK, I know, "on the heap.") But I want to know what it is associated with in memory. Is it treated like part of Child? Is there really a Parent object on the heap and Child simply contains references to the parts of Parent that it inherited? What?
public class Sphere { public double diameter; public double volume; public double area; public double fourThirds = 4/3; public Sphere(double someDiameter){ someDiameter = diameter;
[Code] ....
I am trying to get this code so that I only enter the diameter once in the sphere object1 = new Sphere(4); but I can't get it to work right. I can get the diameter to work with the calculate volume and area methods but that's it.
Im writing a simple program to understand classes and objects. Basically what I have is a file called Program.java where I have my main method.I have another file called Person.java which I want to use to create Person objects. That person can have a name, email adress, phone number, etc.I put both these files in the same folder.in Program.java my first statement is:
My problem is that when I compile Program.java i get an error message saying that the package Person.java does not exist.So my question is, when you create a class that you want to use for objects, how do you import that class into your class with the main method so that you can use instances of your other class?
// Add range to Vehicle. class Vehicle { int passengers; // number of passengers int fuelcap; // fuel capacity in gallons int mpg; // fuel consumption in miles per gallon
// Display the range. void range() { System.out.println("Range is " + fuelcap * mpg);
[Code] ....
I'm compiling it in Eclipse and this continues to show in the console display
Minivan can carry 7. Exception in thread "main" java.lang.NoSuchMethodError: Vehicle.range()V at AddMeth.main(AddMeth.java:34)
Need to use a ComboBox from another class (Beginning Java forum at JavaRanch)
When my file is saved it has the values off the main gui's comboBox in variable 'env' which I then write to file using. I just need to access the comboBox in my second class so I can use it in main as I'm using the wrong one atm- if that makes sense?
I have a program with 4 classes, all of them in the same package, one of them is the Main class, and in that class I declared a variable named "port" of type int. One of the 3 another ones is the class Connection class, which it requires the port variable. I want to use this variable in the Connection class. How can I do it?Both classes are shown below:
Main.java package server; /* Imports */ /* Another variables */ int port; /* <-- IS THIS ONE */
import java.io.FileNotFoundException; public class PrimaClasse { public static void main(String[] args) throws FileNotFoundException { SecondaClasse oggettoSeconda = new SecondaClasse(); oggettoSeconda.controlloNomi();
[code]....
Now it's working and from the main class i can controll the second class BUT. i want that is the main class that ask the user name, and i want pass that value to the second class. what code i must change?why eclipse wants me insert this import java.io.FileNotFoundException; and this throws FileNotFoundException for not give me an error?
I'm currently working on a loan calculator... The only problem I'm having is occasional values that have very long decimals... How do I round the decimals?
I'm making a loan calculator that uses compound interest... I need the program to return the monthly payment, how much of it is principal and how much of it is interest, which depends on how many months into your loan you are... So basically all I need is the algorithm to calculate how much of your monthly payment (depending on how many months in you are) is interest and how much of it is principal.
In summary, the Class XCopy's Main method creates an instance of the XCopy Class. So, now knowing that this can and does occur my next questions to myself were:
When would I do this? How can this best be used?
Is this just another option available to a Java developer that has no other special significance?So far have no answers for myself.
calculate how long it would take to pay off a loan of 500 pounds if there was 10% interest monthly, and 100 pounds was paid each month. This code is in a pseudocode,
set months = 1 set balance = 500 set totalpaid = 0; while balance > 100 balance = balance - 100; set interest = balance * 0.1 balance = balance + interest totalpaid = totalpaid + 100 months = months + 1 endwhile totalpaid = totalpaid+balance display "you paid "+totalpaid display "It took you "+months+" months"
so I had to make a program that prompts the user to enter a loan amount and the years for the loan and I have the conversions and everything my only issue is that when the chart pops up it just looks like a bunch of numbers and its missing the column headers
for example
Interest Rate Monthly Payment Total Payment
import java.util.Scanner; public class InterestRate { public static void main(String[] args) { double monthlypayment = 0; double totalpayment = 0; Scanner input = new Scanner(System.in); System.out.println("Enter Loan Amount");
I've written a program just for the sake of it (to learn) and it seem's like theres quite a lot in the main method that perhaps could be split up into seperate classes. I'm not too sure where should start with this though, or what my thought process should have been as I was writing the program.
import java.util.Scanner; public class Loops { public static void main(String[] args) { int answer = 16; Scanner scan = new Scanner(System.in); // Question System.out.println("What is 4 x 4 ?");
[code]...
--- Update ---
here's a version without code comments as they might make it harder to read here -
import java.util.Scanner; public class Loops { public static void main(String[] args) { int answer = 16; Scanner scan = new Scanner(System.in); System.out.println("What is 4 x 4 ?"); int userAnswerInt = 0;
I have permanently set the path of bin of JDK 1.6 in the environment variables of my system. I am able to compile any of my java programs successfully. But when I give command to run the program I am getting an error "could not find or load main class".
When I write the command "set classpath=.;" program runs successfully. I want to know whether I have to set this classpath everytime I run a new progaram. Is there any permanent way to set classpath ?
I creates this simple code (shown below) inside a package of a major opensource code (i.e., openSHA), but when i run it the following error appears. The error mentions a class named "KT_testGmpeForScenarioRupture" that i wrote before and did not run showing exactly the same error.
Code:
package org.opensha.sha.gcim.imr.attenRelImpl; public class KT_Test { private static void main(String args) { int x=4; System.out.println("x is " + x); } }
Error: Could not find or load main class org.opensha.sha.gcim.imr.attenRelImpl.KT_testGmpeF orScenarioRupture
I have few queries regarding compiling v/s execution of a java program. Suppose I have a Main Class which is referring to class Test which is present in JarA. Now, at compile time, this jar JarA must be present in classpath/buildpath. So, what actually is the action performed by the compiler by referring to this jar?
Now, at runtime also, this jar should be present to execute the Main class. Is this correct? If yes, then what is the action performed by JRE when it refers to this class at runtime? WOn't all the dependencies be resolved at compile time only?
This time I have to make a Black Jack game ( I guess this is a classic) I have created Three classes for this BlackJack( Main), Card, and Player.
What I am trying to do is put the Give one card to the player and remove it from the deck into a separate procedure because I will be doing this several times during the game.
This is the code I have so far Under the class BlackJack.
I am using Netbeans as my IDE and I have created a program called Saluton.java
I navigate to the folder holding the class file using the command line under Windows 7 but when I issue the command java Saluton.class I get an error it cannot load or find the main class.