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
ADVERTISEMENT
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
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
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
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
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
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
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
Aug 2, 2014
i have a run time error that could not find or load the main file java .
View Replies
View Related
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
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
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
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
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
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
Jan 8, 2014
I've 3 classes.
1. Circle
2. GetInputFromUser
3. testCircle
package ABC;
public class Circle {
private double radius;
public double getRadius() {
return radius;
[Code] .....
In the testCircle class, in the line: getRadius = ui1.GetInput();
It's showing the error: The method GetInput(float) in the type GetInputFromUser is not applicable for the arguments ()
And when I do: getRadius = ui1.GetInput(rad);
It's showing the error: rad cannot be resolved
View Replies
View Related
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
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
View Related
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
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
Oct 26, 2014
I am following a tutorial to write a 2d game from scratch in java but when I compile and run my code the application (JFrame) doesn't come up on my screen, it just runs for a second and terminates itself for some reason.
package com.thecherno.rain;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame;
public class Game extends Canvas implements Runnable{
private static final long serialVersionUID = 1L;
[code]....
View Replies
View Related
Feb 26, 2015
I have a list of uninstanciated class types and I wanted to call a static function from these "Class<? extends PropControl>" (without using reflection) that would create a new corresponding object instance but it appears I cant do that in java so now I want to create a factory that takes a class type as aparameter to create the corresponding object instance but this code dont compile:
Java Code:
public PropControl Create(Class<? extends PropControl> cls)
{
if(cls==HouseControl.class) <---- ERROR
{
here I create a new instance of HouseControl (that inherits PropControl)
}
} mh_sh_highlight_all('java');
I get this error :
incomparable types: Class<CAP#1> and Class<HouseControl>
where CAP#1 is a fresh type-variable:
CAP#1 extends PropControl from capture of ? extends PropControl
how do I achieve this ?
View Replies
View Related
Oct 28, 2014
I've got a problem in Eclipse. The below code is a part of my program, used for (re)starting a new game. The 'public static int' statement gives the error 'This method must return a result of type int'..
public static int playAgain(){
boolean validInput = false;
do {
System.out.println("Would you like to play a game? Please answer 'yes' or 'no'.");
String playAgain = input.next();
[Code] ....
View Replies
View Related
Jan 2, 2015
I downloaded this code from Head First Java. But when I tried running it on Eclipse, it gives this error message.
import javax.sound.midi.*;
public class MiniMiniMusicApp { // this is the first one
public static void main(String[] args) {
MiniMiniMusicApp mini = new MiniMiniMusicApp();
mini.play();
[code]....
and this was the error message: Jan 02, 2015 8:10:36 PM java.util.prefs.WindowsPreferences <init>Could not open/create prefs root node Software Java SoftPrefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
View Replies
View Related
Oct 1, 2014
I have style sheet file (e.g. myStyle.xslt). I am trying to decide where to put this file in my web application so that both src and test can access it. All my source in packages inside /src folder and test code in packages inside /test folder.
View Replies
View Related
Nov 1, 2011
I'm developing a JavaEE system with several applications on a Weblogic AS (10.3.5) using Eclipse indigo with OEPE plugin. I turned my computer off, turned it back on, started the eclipse, and all of a sudden I get class-path errors all over the place (didn't change a thing).
Now let me get this straight:
1. Say I have an application with one EAR project that contains an EJB project and an EJBClient project (both in the deployment assembly).
2. I have written a new regular Java project, and I want to use it in both the EJB and EJBClient projects (it needs to be visible to them).
3. As far as I know, I can simply add this Java project to the EAR project's deployment assembly, and it will be visible to the EJB and EJBClient projects.
4. This has been working for me so far, but now I get class-path errors and I have to add this Java project to the build path of each project.
How should I set the class-path when using JavaEE technology in Eclipse?
View Replies
View Related