Results 1 to 3 of 3
- 04-16-2012, 06:26 PM #1
Member
- Join Date
- Apr 2012
- Location
- Southwest Ohio
- Posts
- 1
- Rep Power
- 0
Java is not finding the Main Class in my jar file...
I am building a multi-player battle simulation game application. I have built the program and successfully built a jar file.
But Java fails to see the main class when I invoke the jar file.
Here is my manifest:
Here is my main class code:Class-Path: GlobalConfig/GlobalConfig.jar
LocalConfig/LocalConfig.jar Dialogs/Dialogs.jar
SupportCode/SupportCode.jar
Main-Class: AdminClient
The code compiles and create the jar without errors.//
// Description: Admin Client.
//
// Disk Filename: AdminClient.java
//
// Written By: Allan P. Clapp
//
// Copyright (c) 2012 Allan P. Clapp, All Rights Reserved.
//
import java.io.*;
import java.awt.event.*;
import AdminClientForms.*;
import GlobalConfig.*;
import LocalConfig.*;
import Dialogs.*;
public class AdminClient
{
private
static Object MainFrameCloseLock;
static AdminUserInfo ThisUsersInfo;
static TheServerConnectionInfoScreen ServerConnectInfo;
static AdminUserLoginScreen TheUserLoginScreen;
static MainForm TheMainForm;
public static void main (String args[])
throws IOException, NullPointerException
{
//
// PROGRAM LOGIC NOTE: This call to
// DomainInfo.TheConnectionWasEstablished () MUST BE BEFORE the objects
// are constructed!
//
//
// Get the Connection Information.
//
// NOTE: This "should" only happen once.
//
if (!(DomainInfo.TheConnectionWasEstablished ()))
{
ServerConnectInfo = new TheServerConnectionInfoScreen
(new javax.swing.JDialog (),
AdminAreaConfig.GetSiteBanner () + " Connection Information");
if (ServerConnectInfo == null)
{
throw new NullPointerException
("ServerConnectInfo is NULL (AdminClient.main)");
}
ServerConnectInfo.setVisible (true);
}
//
// Create the needed objects.
//
MainFrameCloseLock = new Object();
if (MainFrameCloseLock == null)
{
throw new NullPointerException
("MainFrameCloseLock is NULL (AdminClient.main)");
}
ThisUsersInfo = new AdminUserInfo ();
if (ThisUsersInfo == null)
{
throw new NullPointerException
("ThisUsersInfo is NULL (AdminClient.main)");
}
ServerConnectInfo = new TheServerConnectionInfoScreen
(new javax.swing.JDialog (),
AdminAreaConfig.GetSiteBanner () +
" Server Connection Information");
if (ServerConnectInfo == null)
{
throw new NullPointerException
("ServerConnectInfo is NULL (AdminClient.main)");
}
TheUserLoginScreen = new AdminUserLoginScreen
(new javax.swing.JDialog (),
AdminAreaConfig.GetSiteBanner (),
AdminAreaConfig.GetAreaName (),
ThisUsersInfo);
if (TheUserLoginScreen == null)
{
throw new NullPointerException
("TheUserLoginScreen is NULL (AdminClient.main)");
}
TheMainForm = new MainForm ();
if (TheMainForm == null)
{
throw new NullPointerException
("TheMainForm is NULL (AdminClient.main)");
}
//
//
// Execute the main logic.
//
//
//
// Log the user in.
//
// TheUserLoginScreen.setVisible (true);
//
// The User closed the login window without logging in so shutdown.
//
if (!(ThisUsersInfo.GetUserIsLoggedIn ()))
{
// System.exit (0);
}
//System.out.println ("Users Name: " + ThisUsersInfo.GetName ());
//System.out.println ("Users Initials: " + ThisUsersInfo.GetInitials ());
//System.out.println ("System Wide Priv: " +
// ThisUsersInfo.GetEnableSystemWidePrivilages ());
//
// The user is logged in so show the main screen.
//
TheMainForm.setVisible (true);
Thread TheThread = new Thread()
{
public void run()
{
synchronized(MainFrameCloseLock)
{
while (TheMainForm.isVisible())
{
try
{
MainFrameCloseLock.wait();
}
catch (InterruptedException e)
{
}
} // while (TheMainForm.isVisible())
} // synchronized(MainFrameCloseLock)
} // public void run()
}; // Thread t = new Thread()
TheThread.start();
//
// Wait for the user to close the main window.
//
TheMainForm.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent arg0)
{
synchronized (MainFrameCloseLock)
{
//
// When they do shutdown thre program.
//
TheMainForm.setVisible(false);
MainFrameCloseLock.notify();
System.exit (0);
}
}
}); // TheMainForm.addWindowListener(new WindowAdapter()
} // public static void main (String args[])
} // public class AdminClient
But when I invoke the Jar file I get this:
allan@INetMach:~/DevSFB$ java -jar AdminClient.jar
Exception in thread "main" java.lang.NoClassDefFoundError: AdminClient$1
Caused by: java.lang.ClassNotFoundException: AdminClient$1
at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:334)
Could not find the main class: AdminClient. Program will exit.
I do realize that theindicates an anonymous inner class. But There should not be one. I tried placing the main program in a package but that did not work either.AdminClient$1
Any help in this matter will be appreciated.
- 04-16-2012, 06:36 PM #2
Re: Java is not finding the Main Class in my jar file...
Use code tags, not quote tags, for posting code.
BB Code List - Java Programming Forum
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-16-2012, 06:49 PM #3
Re: Java is not finding the Main Class in my jar file...
Did you look in the folder where the class files are written by the compiler to see if that class file was there?There should not be one.
How are you creating the jar file?If you don't understand my response, don't ignore it, ask a question.
Similar Threads
-
.jar file cant find main class
By eLancaster in forum New To JavaReplies: 3Last Post: 02-10-2011, 11:17 AM -
Pls. Help with finding Main Class
By DetRich in forum New To JavaReplies: 1Last Post: 11-09-2010, 05:27 PM -
Separate file for main and class
By eel in forum New To JavaReplies: 12Last Post: 09-18-2010, 08:24 AM -
Finding Jar files in a class file
By bnrkcdc in forum Jobs DiscussionReplies: 4Last Post: 09-08-2010, 01:46 PM -
Jar file could not find the main class
By Collinryans in forum New To JavaReplies: 3Last Post: 06-23-2010, 04:18 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks