JGrasp - No Main Method / Applet Or IMDlet

Sep 30, 2014

I have been trying to get this code to work but in jGrasp it give the no main method, applet, or IMDlet. The assignment states: Design a class Message that models an e-mail message. A message has a recipient, a sender, and a message text. Support the following methods:

-A constructor that takes the sender and recipient
-A method append that appends a line of text to the message body a method toString that makes the message into one long string like this:

"From:Harry Morgan
To: Rudolf Reindeer. . ."

Write a program that uses this class to make a message and print it. package emailmodel;

import java.util.Scanner;
public class Message
{
private String senderemail;
private String receiveremail;

[code]....

View Replies


ADVERTISEMENT

Don't Need Main In Applet?

Apr 3, 2014

Why we do not need main in applet .....

View Replies View Related

Calling Applet From Another Class Main Menu

Aug 20, 2014

I have a frame which I want to load an applet inside it. Here is the code i have in my main method:

MyApplet myApplet = new MyApplet();
myApplet.init();
myApplet.start();
javax.swing.JFrame window = new javax.swing.JFrame("myApplet");
window.setContentPane(myApplet);
window.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);

But I get an exception:

Quote
Exception in thread "main" java.lang.NullPointerException
at java.applet.Applet.getCodeBase(Applet.java:169)
at MyApplet.init(MyApplet.java:78)
at Intro.main(Intro.java:68)
Java Result: 1

View Replies View Related

How To Return Array From A Method / Back Into Main Method That Prints Out Stuff

May 27, 2014

I'd like to know how to return a new array, I wrote in a method below the main method. I want to print the array but system.out.print doesn't work for arrays apparently. What structure i should use?

View Replies View Related

Writing A Method That Returns Words Without Four Letters Back To Main Method

May 27, 2014

I have to write a method called censor that gets an array of strings from the user as an argument and then returns an array of strings that contains all of the original strings in the same order except those with length of 4. For example if cat, dog, moose, lazy, with was entered, then it would return the exact same thing except for the words with and lazy.

Currently, my code so far just prints [Ljava.lang.String;@38cfdf and im stuck.

import java.util.Scanner;
 public class censorProgram {
public static void main (String args[]){
Scanner input = new Scanner (System.in);
System.out.println ("How many words would you like to enter?");
int lineOfText = input.nextInt();
 
[Code] ....

I have to make new string array in the method and return words without four letters in the main method

View Replies View Related

How To Call A Method That Exist Within A Class Into Main Method

Feb 13, 2014

I am just trying to test this array, for a locker combination program that involves classes...but the array is printing out the whacky numbers for the location. When I try to call the method in the main, it does not work. How do I call a method that exist within a class into the main method?

public class locker { 
public static void main(String[] args) {
CombinationLock();

[code]....

View Replies View Related

Calling Method Into Applet

Apr 8, 2014

I need to create an applet that displays a grid of command buttons which I have done. I then need to create a new class that draws a silly picture of an alien, which I have also done. Where I am completely stuck and confused, is that I do not know how to get the drawing into the applet. My code is below. I really do not fully understand why this is not working or how to get it working.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MartianGame extends JApplet implements ActionListener {
DrawMartian aMartian = new DrawMartian();
DrawJupiterian aJupiterian = new DrawJupiterian();

[Code] .....

View Replies View Related

Main Method Separated From Other Method

Jan 13, 2014

Here's a class called Fibonacci

Java Code:

public class Fibonacci {
public static int fib(int n) {
if (n < 2) {return n;}
else {return fib(n-1)+fib(n-2);}

[code]....

it contains one method called fib() and one main method.If I would want to have the main method in another class than fib(), how would I write the two classes? Only cutting the main method from this class to another one doesn't work.My question is, is the reason it doesn't work because I then would have to have a constructor in the Fibonacci class, and create a Fibonacci object first which I then use the method on?

View Replies View Related

Creating Applet With Dropdown Lists - Method Not Abstract

Oct 21, 2011

i am trying to create an applet with drop-down lists. When I compile the program the following error message appears '. . .is not abstract and doesn't override abstract method action Performed. . . Here is my code . . .

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DavidApplet extends Applet implements ActionListener //class header {
Label fName=new Label("First Name");

[Code] .....

View Replies View Related

Applet Viewer - Show Status Method Not Working

Apr 6, 2014

import javax.swing.*;
import java.awt.*;
import java.net.*;
import java.io.*;
public class App extends JApplet{
public void init(){
showStatus("applet");
}
}

This code does nothing to my statusbar.

I use applet viewer for my applet.

View Replies View Related

Java Applet - Using Constructor To Populate Deck Of Cards Instead Of Method

Sep 14, 2014

I have two questions.

1 - I don't understand why I'm getting an empty stack error when calling the removecard method in my Table class line 13?

2 - I am trying to use a constructor to populate my deck of cards instead of a method when creating my theDeck object in my Table class line 11 but I get the following error:

java.lang.StackOverflowError
at java.util.Vector.<init>(Unknown Source)
at java.util.Vector.<init>(Unknown Source)
at java.util.Stack.<init>(Unknown Source)
at Deck.<init>(Deck.java:7)
at Deck.<init>(Deck.java:34)

public class Card {
 String enseigne;
int valeur;
 
[Code]....

View Replies View Related

No Main Method?

Jul 23, 2014

I'm trying to make a TBG (Text Based Game) in Java for Android. Now, when I try to run it, it says No Main Method to run this program. The compiler also checks the program and tell me there are no errors.

View Replies View Related

Why Is Main Method Static

Oct 1, 2014

in java why main method is always static in nature...

View Replies View Related

Calling A Method From Main

Jan 26, 2014

The idea is to create a program to add plants and retrieve plants from a Nursery. I created a class with the properties of the plants and also there is the class an Array list to keep track of the plants entered ( they will have to be printed later) (I am not too sure if adding a public class there is the best option.

The program will allow the user to pick and action and from there the code will do something. I don't want to have all the code inside 'main' The problem is in line 114.This is what I have so far.

Java Code:

package plant.nursery;
import java.util.ArrayList;
import java.util.Scanner;
/**Class to create a plant for a nursery.
public class PlantNursery

[code]....

View Replies View Related

Define Main Method

Apr 26, 2014

this is my program error occured run time,but compile sucessfully

{error msg-Error: Main method not found in class helloworldapp.HelloWorldApp, please define the main method as:
public static void main(String[] args)}
class HelloWorldApp
{
private int empno;
private float salary;
void setHelloWorldApp()
{
empno=12;
salary=1200;

[code]....

View Replies View Related

Calling A Method To Main

Nov 17, 2014

I'm trying to call a method to my main method, but I can't seem to get it to work and it keeps resulting in a compile error.

import java.io.*;
import java.awt.Point;
import java.text.DecimalFormat;
import java.util.Random;
public class Chase {
public static void main(String args[]){

[Code] .....

View Replies View Related

Calling A Method To The Main

Sep 10, 2014

I have been reading about methods and I do have a beginner level understanding on how they work. I was trying to mess around and make a dog calculator using methods. I ran into a small snag; I cannot get the method to call to the main or the program to compile correctly. The first code below is the original. To me it looks like (based off of some examples I looked at) there should be no problems, but NetBeans gives me a few errors. 1) line 8- "cannot find symbol, variable dogYearCalc; 2) line 18 illegal start of expression; and 3) line 22 - unreachable statement.

import javax.swing.JOptionPane;
public class KrisExample {
public static void main (String[] args) {
double dogYears = 0;
JOptionPane.showInputDialog (null,"Please enter you dog's age in human years:");

[Code] ....

Someone told me that I was calling dogYearCalc without any arguments in your main method. I take that to mean that I needed to add it to the main, so I did here:

public static void main (String[] args, double dogYearCalc) {

That got rid of my first error, but then when I tried to run the program NetBeans said that I have no main class, so switched back to the original program above.

I thought that when I calling the dogYearCalc method on line 10 was the whole purpose of using a method. It seems to me that putting it somewhere in the main is counter productive.

View Replies View Related

Recall Main Method After Calling Of JVM?

Jul 28, 2014

Can we recall the main method? I'm trying a code to recall main method (after the calling of JVM). I know this doesn't make any sense but I'm trying this just like that.

Code:

class derived {
public static void main(String args[]) {
System.out.println("Main Method class");
show();
}
static void show()

[code]....

View Replies View Related

Splitting Up Main Method / Class?

Jan 29, 2014

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;

[code]...

View Replies View Related

Void And Static In Main Method?

Jan 7, 2014

What does void and static mean in the main method?

View Replies View Related

How To Have Multiple Classes But Only One Main Method

Nov 1, 2014

I was reading the book, "Head First Java" and it was talking about how there may be multiple classes in a large application, but there will be only one main method.how does it work that way? How can you have multiple classes, but only one main method?

View Replies View Related

Access A Method Of Class From Main

Feb 9, 2014

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.

Java Code:

package black.jack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

[Code] .....

View Replies View Related

Cannot Call Child Method From Main

May 7, 2015

I can call a child method from a main method. If I have a parent called "Assessment", a child called "Quiz", and another child called "test". Can I instinate an object like Assessment a = new test(); and call a method in test.I know the method can be called if I instinate the test t = new test() but that defeats the purpose of inheritance which I'm learning in class.

View Replies View Related

Calling Object To Main Method

Oct 26, 2014

When I try to call an object it can't find the symbol in the argument list. NetBeans says that it cannot find the movieCategory symbol when I try to call it. When I compile it to test a popup comes up that states "One or more projects were compiled with errors. Application you are running may end unexpectedly. I ran it anyways and everything runs up to the point of where it should call the object.

At this point it should get the Movie object and run the code within that, but if I put one of the categories it throws. "Exception in thread "main" java. lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>at MovieApp.main(MovieApp.java:33)Java Result: 1"

From my understanding to call an object it requires objectName.methodName(argumentList). Here is my Main method

/**
*This application will store a list of 100 movies and display them by category
*/
import java.util.Scanner;
public class MovieApp
{
public static void main(String args[])
{
//Displays <code>String</code> welcome message
System.out.println("Welcome to the Movie Application.");
System.out.println("There are 100 movies in the list.");
System.out.println("What category are you interested in?");
System.out.println();

[code].....

View Replies View Related

Return Int X To Main Method And Print It Out

Oct 10, 2014

I tried to create a simple program. The main method is supposed to call out the secondary method to use Scanner in order to ask a person to type in a number, which will be assigned to int x. Then the secondary method supposed to return the int x to main method, which supposed to print it out. And for some reason I just can't do it. No matter what the main method refusing to accept the int x.

import java.util.Scanner;
public class Return{
static Scanner newNum= new Scanner(System.in);
public static void main(String[] args){
getInt();
System.out.println(x);
}
public static getInt( ) {
// TODO Auto-generated method stub
int x;
System.out.print("give a num");
x= newNum.nextInt();
return x;
}}

View Replies View Related

Why Main Method Has Argument String

Oct 6, 2014

One interviewer has asked me one question that why main() method has argument "String[] arg".What is reason behind this ??I am unable to explain it because i never think about it ..

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved