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:
Quote:
Class-Path: GlobalConfig/GlobalConfig.jar
LocalConfig/LocalConfig.jar Dialogs/Dialogs.jar
SupportCode/SupportCode.jar
Main-Class: AdminClient
Here is my main class code:
Quote:
//
// 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
The code compiles and create the jar without errors.
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 the indicates 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.
Any help in this matter will be appreciated.
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
db
Re: Java is not finding the Main Class in my jar file...
Quote:
There should not be one.
Did you look in the folder where the class files are written by the compiler to see if that class file was there?
How are you creating the jar file?