Could Not Find Main Class - Program Will Exit

Jan 24, 2015

This is my first java program,i am using eclipse IDE-----

package day1.example;

public class MyFirstJava {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("hi");
}
}

When i saved it,it shows no error.when i run it then a pop-up says "could not find the main class.the program will exit" and in the console it says---

java.lang.UnsupportedClassVersionError: day1/example/MyFirstJava : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
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)

[Code] ......

View Replies


ADVERTISEMENT

JDK 1.6 - Could Not Find Or Load Main Class

Sep 23, 2014

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 ?

View Replies View Related

Could Not Find Or Load Main Class

Mar 1, 2015

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

View Replies View Related

Cannot Find Or Load Main Class

Nov 19, 2014

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.

View Replies View Related

Error Could Not Find Or Run Main Class

Jan 7, 2014

I made a breakout like game that runs as a applet and now i wanted to make it run in a jframe so i wrote this

Java Code:

import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
public class BrickBuster{
public static void main(String[] args){
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
JApplet BrickBuster = new JApplet();
frame.add(BrickBuster);
BrickBuster.init();
}
} mh_sh_highlight_all('java');

It compiles fine but whenever i try running it with the java command it says it couldnt find or load main class. also i have it save in a folder called BrickBuster so i called java BrickBusterBrickBuster.class

View Replies View Related

Could Not Find Or Load Main Class In CMD

Sep 23, 2014

I tried running my program on cmd but it produces the error "could not find or load main class" ...It compiles well but it just doesn't run. Here is my code:

package writedoc;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;
public class WriteDoc {
public static void main(String[] args) throws IOException {
String strDocument="grades.txt";

[Code] ....

View Replies View Related

JavaDigest - Could Not Find Or Load Main Class

Nov 15, 2014

Could not find or load the main class.

package in.javadigest.encryption;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.KeyPair;

[Code] ....

Its compiling the compiled class is in C:programsclass folder. Iam running the program using the following commands...

javac MainClass2.java // This is working fine
java -cp C:programsclass MainClass2

View Replies View Related

Could Not Find Or Load Main Class Error

Sep 13, 2014

I have a problem that happens randomly where i try to compile and it just comes up with error

"Error: Could not find or load main class com.productiontrackingscreens.rexam.EmployeeAddressList"

This is a program that worked fine until i started it today. Seems a bug with eclipse.

View Replies View Related

Error - Could Not Find Or Load Main Class

Sep 30, 2014

I'm trying to run a java program from cmd. I'm using Windows 8, java version "1.8_0_20". I've got two classes, the main class called Middleware and a secondary class, called WorkerThread, of which the main class is using functions. I've successfully compiled both .java files with javac, and created the .class file. So all files are in the same folder. However, when I attempt to run the main class with java Middleware, I get the error message: "Error: Could not find or load main class". Here's the main class:

package middleware;
import java.net.*;
import java.util.concurrent.*;
public class Middleware {
//Number of threads serving clients.
private static int nr_threads = 5;
private static int portNr = 6789;
private static ServerSocket welcomeSocket;
private static ExecutorService executor;

[code]....

My code compiles and runs fine in eclipse but on the console, I'm having troubles.

View Replies View Related

Stuck On Error - Could Not Find Or Load Main Class

Sep 2, 2014

I'm getting an error trying to run a welcome app from a book. I've looked at the FAQs and can't seem to solve the issue. I'm guessing my path and/or classpath are not right. Here's my path environment variable.

C:jdk1.8.0_20in;C:ProgramDataOracleJavajavapath;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerSh

[Code] ....

Here's my output.

09/01/2014 10:23 PM 634 Welcome.class
09/01/2014 10:21 PM 422 Welcome.java
14 File(s) 126,243,703 bytes
9 Dir(s) 53,942,079,488 bytes free

[Code] .....

It looks like the version command gives me what it should, so it appears I've got java setup right, but I"m stuck on the error I'm getting :

C:jdk1.8.0_20>javac -version
javac 1.8.0_20
C:jdk1.8.0_20>

View Replies View Related

Error - Could Not Find Or Load Main Class GameTester

Oct 29, 2014

I was trying to write my own version of the game SimpleDotCom from Head First Java. I have two files:

Game.java:
package project_01;
public class Game{
byte hitCount = 0;
String result = "miss";
int counter = 0;
String checkGuess(int[] location,int userGuess){

[Code] .....

The two files are in the same directory, "project_01" and the CLASSPATH environment variable is set to ".;".
The game compiled but when I tried launching it with "java GameTester" it returned the error : Could not find or load main class GameTester. I know my game is horrible and probably extremely buggy but I'll fix all the bugs, etc. later, right now I just need to get it to run.

View Replies View Related

Error / Could Not Find Or Load Main Class HelloWorld

Jan 8, 2015

My problem is that I can compile a java HelloWorld program using javac HelloWorld.java but I cannot run the program using java HelloWorld. I didn't create the code it was developed by a professional programmer. My assignment is to compile and run, so that I see the output.

View Replies View Related

Could Not Find Or Load Main Class HelloWorld - Notepad++

Dec 11, 2014

I'm new to this java stuff and when I go to notepad++ and this keeps coming up when I try to compile it: "Error: Could not find or load main class HelloWorld" what it means...

View Replies View Related

Declaring Enums - Could Not Find Or Load Main Class

Feb 25, 2014

I've just started, so right now I'm reading about declaring enums, the book lists the following code

enum CoffeeSize {
//8,10 & 16 are passed to the constuctor
BIG(6), HUGE(10), OVERWHELMING(16);
CoffeeSize(int ounces){ //constructor
this.ounces = ounces;

[Code] .....

I'm assuming that code to be in a same file since enums can be declared within and outside a class, so I saved it into a file named "Coffee.java", it compiles just fine from command line but when I try to execute "java Coffee" it throws "Error: Could not find or load main class Coffee"...

View Replies View Related

Running Encryption / Decryption Application - Could Not Find Main Class

Jun 23, 2014

I am trying to put together an encryption/decryption application that will essentially accept a sentence that is submitted, and spit out the encrypted version and then switch it back to the correct sentence. I have been told to nest my information in the class (rather than the main), but am having difficulty actually understanding how to do this. The error that Eclipse is throwing me is also that it "could not find the main class." Here is my code:

import java.util.Arrays;
import java.util.Random;
public class encryptingWords {
public static void main(String[] args) {
final int ALPHASIZE = 26;
final char[] Lalpha =

[Code] .....

View Replies View Related

Using Java From DOS Command Line - Cannot Find Or Load Main Class

Nov 10, 2013

When I try to run Java from the Windows DOS command line, I'm running into trouble:
 
1. When I run Java from the wrong directory, I get the error Error: cannot find or load main class myapp1.
 
2. When I get to the "right" directory (.../MyApp1/build/classes/myapp1/, which is where the MyApp1.class file resides), I get the following error:
 
Exception in thread "main" java.lang.NoClassDefFoundError: MyApp1 (wrong name: myapp1/MyApp1)
 
1. The CLASSPATH variable is not set (when I type echo %CLASSPATH% the system returns %CLASSPATH%).

2. I also get the same error above when I use: > java -cp . myapp1

3. I've made sure the PATH is set correctly in environment variables, with the Java path at the beginning of the path string).

View Replies View Related

Using Eclipse To Maintain Java Application - Could Not Find Main Class Error

Sep 3, 2014

I currently use Eclipse to maintain our Java application. I recently upgraded from Java 6 to Java 7. I updated my Eclipse projects to use the Java 7 .jar files. I can run the application from Eclipse via the Run Configuration.

I can also run the Ant build and it completes successfully. When I install the application on my desktop, I receive the "Java Virtual Machine Launcher: Could not find main class..." error. My CLASSPATH is set to ".".

View Replies View Related

Compiling And Running Program With No Main Class / How Is That Possible

Mar 22, 2014

I made a software using Netbeans and javaswing. Accidently i deleted my main file which contains my main class and main method. Just to test, i tried to compile and run and it worked but the style of my buttons and windows has changed. So, what happened? How can i change the style of my programs?

//File Accidently deleted
package time;
public class Time {
public static void main( String[] args ) {
Window wdow = new Window();
wdow.setVisible( true );
}
}

View Replies View Related

Exit Program When Nothing Is Input

Apr 16, 2014

If a user inputs nothing the code should end ... How Should i do it?

import java.util.Scanner;
public class MyQueue<T> implements Queue<T> {
private T[] ringbuffer;
static int capacity = 0;
int mysize = 0;

[Code] ....

View Replies View Related

How To Input Exit Code Into Program

Mar 12, 2014

I just want to know how I can get my program to end when the user inputs "0." By using: System.exit(0);

import java.util.Scanner;  
public class TestCode
{
public static void main (String [ ]args ) {
Scanner console =new Scanner(System.in);
System.out.println("To exit program input 0");
for (int y = 1; y < 11; y++ ){ // Executes output 10 times
 
[code]....

View Replies View Related

I/O / Streams :: File Not Created Until Program Exit

Aug 28, 2014

I have been going over my code line by line, over and over again for nearly and hour now...When I execute method `file.createNewFile()`, the method returns true and throws no exceptions. It even says that the file exists. However, the file is not created and cannot be accessed until the program has exited.

File portLib = new File("");
private class RememberPortAction extends AbstractMenuItemAction
{
methods...
protected void actionPerformed() {
LibraryCreator creator = new LibraryCreator(self, logger);
File newPortLib;

[code]....

View Replies View Related

Program Will Print Out Largest Number And Exit

Oct 1, 2014

Description of the program: read a sequence of positive integers from terminal. When user types

-1, the program will print out the largest number and exit.

Program mid.java
import java.util.Scanner;
public class test
{
public static int num;
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);
num = in.nextInt();
int large = num;
while(num > 0);
{
if(0 > num && num > large)
large = num;
}
System.out.println("The largest number is : " + large);
}
}

View Replies View Related

How To Exit A Java Program If User Input Nothing

Apr 17, 2014

How do i exit a java program is the user input is nothing "",This is my code

Java Code:

import java.util.Scanner;
public class MyQueue<T> implements Queue<T> {
private T[] ringbuffer;
static int capacity = 0;
int mysize = 0;

[code]....

View Replies View Related

Program Repeat Until User Enters Number 4 To Exit?

Feb 18, 2014

My question is how can I make the program repeat until the user enters the number 4 to exit?
 
/**
* Write an application for a furniture company; the program determines the price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany. The output is the name of the wood chosen as well as the price of the table. Pine table cost $100, oak tables cost $225, and mahogany table cost $310. Also ask the user to specify a

(1) large table or a
(2) small table.

Add $35 to the price of any large table and add nothing to the price for a small table. Display the output. Your program must repeat until the user chooses to exit.

*/
import java.util.Scanner;
public class Wood {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println ("Table Prices");

[Code] .....

View Replies View Related

Program Should Exit Repetition Loop And Compute And Display Average Of Valid Grades Entered

Oct 26, 2014

My homework assignment is: Using a do-while statement, write a Java program that continuously requests a grade to be entered. If the grade is less than 0 or greater than 100, your program should display an appropriate message informing the user that an invalid grade has been entered; a valid grade should be added to a total. When a grade of 999 is entered, the program should exit the repetition loop and compute and display the average of the valid grades entered. Run the program on your computer and verify the program using appropriate test data.

When I run it, I don't get the correct average. I know that i'm supposed to enter 999 to exit the loop and to display the average, but 999 is being added with the loop. I'm not sure how to make it not do that.

//stephanie
import java.util.Scanner;
public class gradeAverage
{
public static void main(String[] args)

[code]....

View Replies View Related

Error In Main Method - Cannot Find Symbol

Dec 15, 2014

I am writing a palindrome program. I don't understand what is wrong with my Main method. It is giving me error and error is "Can not find symbol in main method"

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PalindromeA extends JFrame {
private JTextField inText;
private JTextField outText;

[Code] ....

View Replies View Related







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