[04:48:05 ERROR]: Could not load 'plugins\HelloWorld.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.spoonle.helloworld.Main'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins(CraftServer.java:291) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:152) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:505) [spigot.jar:git-Spigot-c3c767f-33d5de3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_211]
Caused by: java.lang.ClassNotFoundException: me.spoonle.helloworld.Main
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_211]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_211]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_211]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_211]
at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_211]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot.jar:git-Spigot-c3c767f-33d5de3]
... 7 more
I keep getting this error while loading my plugin onto my test server.
(I did check the other posts and they didn't help me)
plugin.yml file:
name: HelloWorld
version: 1.0
author: Spoonle
main: me.spoonle.helloworld.Main
commands:
hello:
alias: [hi]
do I need to add something? Those are spaces and not tabs. I saw that using TAB can break the yml file so I used spaces instead.
Code:
package me.spoonle.helloworld.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.spoonle.helloworld.Main;
public class HelloCommand implements CommandExecutor {
private Main plugin;
public HelloCommand(Main plugin) {
this.plugin = plugin;
plugin.getCommand("hello").setExecutor(this);
}
#Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players may execute this command!");
return true;
}
Player p = (Player) sender;
if (p.hasPermission("hello.use")) {
p.sendMessage("Hello!");
return true;
} else {
p.sendMessage("You do not have permissions to use this command!");
}
return false;
}
}
This is just what I want the plugin to do. I don't know if this helps but its here if you need it.
Why can't I load my plugin??
Edit: I fixed the invalid plugin.yml. Now it is saying it can't find the main class. As stated above in the plugin.yml code, its me.spoonle.helloworld.Main and thats where my main file is located. How do I fix that now??
Is the plugin.yml file in the same folder as the Main file?
If so, you just have to write
main: Main
Your main class must extend JavaPlugin
Your plugin.yml must state "main: " and then your main class.
There should be a class called Main in the package me.spoonle.helloworld. If so, your main class is in the correct location.
Also, it is not good practice to use Main as your main class. Use the name of your program instead.
Example
Main:
package me.spoonle.helloworld;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
#Override
public void onEnable() {
// Initialise HelloCommand here and set the executor of "hello" command
}
#Override
public void onDisable() {
}
}
Plugin.yml:
name: HelloWorld
version: 1.0
author: Spoonle
main: me.spoonle.helloworld.Main
Related
When I'm testing my new plugin an exception keeps getting thrown: java.lang.IllegalArgumentException: Plugin already initialized! Please help! Here's the code:
package me.plugin.example;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.Listener;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
public class Main extends JavaPlugin implements Listener {
#Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Main(), this);
}
#EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {
Player p = event.getPlayer();
event.setJoinMessage(ChatColor.AQUA + p.getPlayerListName() + " has joined the game.");
p.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Welcome to the server!");
p.setGameMode(GameMode.ADVENTURE);
}
#Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("example")) {
player.sendMessage(ChatColor.BOLD + ""+ ChatColor.ITALIC + "Hello! Hope you like to be set on fire. lol :P");
player.setFireTicks(20);
}
return true;
}
#Override
public void onDisable() {
}
}
I know that you're only supposed to declare one JavaPlugin class per plugin, which I think I'm doing. But it keeps saying:
java.lang.IllegalArgumentException: Plugin already initialized!
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:122) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at me.plugin.example.Main.<init>(Main.java:19) ~[?:?]
at me.plugin.example.Main.onEnable(Main.java:27) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
Caused by: java.lang.IllegalStateException: Initial initialization
at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:125) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at me.plugin.example.Main.<init>(Main.java:19) ~[?:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_201]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_201]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_201]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_201]
at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_201]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
... 2 more
I really need to test this plugin to see if it works, and any help would be greatly appreciated! Thank you!
I would really recommend you to put your event handler in a separate class.
Try removing the below line
getServer().getPluginManager().registerEvents(new Main(), this);
and please don't ask your question several times.
The stacktrace clearly tells where is the problem. What is a stack trace, and how can I use it to debug my application errors?
The error:
java.lang.IllegalArgumentException: Plugin already initialized!
...
Caused by: java.lang.IllegalStateException: Initial initialization
...
at me.plugin.example.Main.<init>(Main.java:19) ~[?:?]
Your code:
#Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Main(), this);
} //<-- 19th line
And the problem is when you register your event you are creating a new instance of your Main class. So replace new Main()
getServer().getPluginManager().registerEvents(new Main(), this);
with this
getServer().getPluginManager().registerEvents(this, this);
PluginAlreadyInitialized error occours when the .jar file contains more than one subclass of JavaPlugin class. Use the JavaPlugin class only once in all plugins from.
I am currently stuck with the following prob. The JAR & Pi4J Lib gets executed on a RasPi B+. I've been searching the web for hours without a result. Curiously looking forward to your reponses and support ;-)
Stacktrace:
Exception in thread "main" java.lang.RuntimeException: Unable to open GPIO direction interface for pin [1]: No such file or directory
at com.pi4j.wiringpi.GpioUtil.export(Native Method)
at com.pi4j.io.gpio.RaspiGpioProvider.export(RaspiGpioProvider.java:108)
at com.pi4j.io.gpio.impl.GpioPinImpl.export(GpioPinImpl.java:158)
at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:517)
at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:669)
at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:681)
at com.test.RemoteImpl.fahreVorwaerts(RemoteImpl.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:178)
at sun.rmi.transport.Transport$1.run(Transport.java:175)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at com.sun.proxy.$Proxy0.fahreVorwaerts(Unknown Source)
at com.client.RMIClient.main(RMIClient.java:19)
package com.test;
The Code:
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import com.interf.test.TestRemote;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPin;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinDirection;
import com.pi4j.io.gpio.PinMode;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.io.gpio.trigger.GpioCallbackTrigger;
import com.pi4j.io.gpio.trigger.GpioPulseStateTrigger;
import com.pi4j.io.gpio.trigger.GpioSetStateTrigger;
import com.pi4j.io.gpio.trigger.GpioSyncStateTrigger;
import com.pi4j.io.gpio.event.GpioPinListener;
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
import com.pi4j.io.gpio.event.GpioPinEvent;
import com.pi4j.io.gpio.event.GpioPinListenerDigital;
import com.pi4j.io.gpio.event.PinEventType;
public class RemoteImpl extends UnicastRemoteObject implements TestRemote {
protected RemoteImpl() throws RemoteException {
super();
}
private static final long serialVersionUID = 1L;
#Override
public boolean isloginvalid(String username) throws RemoteException {
if (username.equals("test")) {
return true;
}
return false;
}
#Override
public void fahreVorwaerts(int dauer) throws RemoteException {
System.out.println("----- EXTCMD: VORWAERTS FAHREN "+"("+ dauer +"ms)" + "-----");
// GPIO CODE SECTION BEGINS
final GpioController gpio = GpioFactory.getInstance();
final GpioPinDigitalOutput pin_gpio01 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, "MyLED", PinState.LOW);
pin_gpio01.pulse(dauer, true);
System.out.println("----- INFO: VORWAERTS FAHREN ENDE -----");
}
}
Life could have been so much easier if I'd just had a look on the GPIO numbering. There is no GPIO01!
Anyway, now it works by choosing an existing GPIO. Cheers :-)
Raspberry pi 3 B GPIO
pi4j; GPIO Input Error? "Unable to open GPIO edge interface for pin ??: No such file or directory"
-Solution-
Coding; gpio.setShutdownOptions(true) instead of myButton.setShutdownoptions(true) or gpio.shutdown()
Compile; Next, use the following command to compile this example program:
$ javac -classpath .:classes:/opt/pi4j/lib/'*' -d . ListenGpioExample.java
Execute the following command will run this example program:
$ sudo java -classpath .:classes:/opt/pi4j/lib/'*' ListenGpioExample
Run with sudo command
sudo java -jar yourjarname.jar
I'm creating a Java RMI program, but I'm getting a ClassNotFoundException.
Could you guys help me figure it out? I'm using Eclipse.
Somebody suggested me it was a codebase problem, but how does this relate?
Here are the codes for my Server and Client:
Server:
package server;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import base.Server;
import base.RmiStarter;
public class ServerImplStarter extends RmiStarter{
public ServerImplStarter() {
super(Server.class);
}
#Override
public void doCustomRmiHandling() {
try{
Server engine = new ServerImpl();
Server engineStub = (Server)UnicastRemoteObject.exportObject(engine, 0);
Registry registry = LocateRegistry.createRegistry( 1099 );
registry = LocateRegistry.getRegistry();
registry.rebind("Server", engineStub);
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args){
new ServerImplStarter();
}
}
Client:
package client;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import base.RmiStarter;
import base.Server;
import base.Cell;
public class CellClient extends RmiStarter {
public CellClient() {
super(Server.class);
}
#Override
public void doCustomRmiHandling() {
try{
Registry registry = LocateRegistry.getRegistry();
Server server = (Server)registry.lookup("Server");
Cell c = null;
c = server.getcell();
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
new CellClient();
}
}
and the error is this:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: server.CellImpl
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy0.getcell(Unknown Source)
at client.CellClient.doCustomRmiHandling(CellClient.java:23)
at base.RmiStarter.<init>(RmiStarter.java:19)
at client.CellClient.<init>(CellClient.java:13)
at client.CellClient.main(CellClient.java:31)
Caused by: java.lang.ClassNotFoundException: server.CellImpl
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at sun.rmi.server.UnicastRef.unmarshalValue(Unknown Source)
... 8 more
Both client and server should have same package name. I had the same error yesterday, i corrected it after lots of searching. Try it and tell me if any other error comes.
Mark this as answer, if you find so.Thank You !!
CellImpl has not been exported or made available via the client's CLASSPATH. It needs to either (a) extend UnicastRemoteObject or be exported via UnicastRemoteObject.exportObject(); or (b) be Serializable and available on the client's CLASSPATH.
Solution for NoClassFound Exception when running RMI Client.
Case:
The server and client files are in different folders.
Example:
Server side: The server interface and server implementation are inside
Project Folder: C:\RMIServer
Package: rmiserver
Client side: The server interface and the client are inside
Project Folder: C:\RMIClient
Package: rmiClient
Problem: Could not find the location of the server interface.
Solution: In the client side,
1. Create a package name rmiServer (the package name should be the same as the server side package).
2. Place the server stub inside this package.
3. The client.java is inside the rmiClient package. Now import the rmiServer package in the client.java file.
import rmiServer.*;
This will solve the classNotFound Exception that happens when we execute the client side RMI.
Today I started coding a project that uses sqlite and when I tried to test it I received the java.lang.ClassFormatError: Invalid pc in LineNumberTable. Hope you can help me with it, because I'm just lost. I'v searched about this error, and came across some weird solutions to some weird causes. As I understand, none of them was causing my problem.
I'm using "sqlitejdbc-v056" wich is inserted in my classpath.
Edit: My JDK version is 1.7.0_03-b05
StackTrace:
Exception in thread "main" java.lang.ClassFormatError: Invalid pc in LineNumberTable in class file Controllers/FuncionariosController
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$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at Main.main(Main.java:13)
Code giving the error:
public class Main {
public static void main(String[] args) {
DatabaseController db=new DatabaseController();
FuncionariosController f=new FuncionariosController(db);
...
}
}
Class FuncionarioController:
package Controllers;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import Models.Funcionario;
public class FuncionariosController {
private DatabaseController db;
public FuncionariosController(DatabaseController db){
this.db=db;
}
public void render(String cargo){
...
}
public List<Funcionario> selectAll(){
...
}
public Funcionario select(String login){
...
}
}
Thanks in advance,
I had a simmilar problem.
It occured that it was caused by switch that haven't got cases code.
While the error occured it looked somtheing like this:
switch(e.getActionCommand()) {
case ACTION_OPEN_PID:
break;
case ACTION_OPEN_PPID:
break;
default:
}
After adding simple console output to the cases the error was gone.
switch(e.getActionCommand()) {
case ACTION_OPEN_PID:
System.out.println(ACTION_OPEN_PID);
break;
case ACTION_OPEN_PPID:
System.out.println(ACTION_OPEN_PPID);
break;
default:
}
Thanks to Luiggi Mendoza I solved it by using JDK 1.6 instead of 1.7. That did the trick, but I had to comment out a lot of code to compile it. Not that good a solution....
I'm working though a book SWT/JFace IN ACTION by Manning Press.
When I added JFace, Eclipse for some reason could not find the main class though it is plainly present.
Here is the code
package com.swtjface.ChTwo;
import org.eclipse.jface.window.*;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class HelloSWT_JFace extends ApplicationWindow{
/**
* #param args
*/
public HelloSWT_JFace(){
super(null);
}
protected Control createContents(Composite parent){
Text helloText = new Text(parent, SWT.CENTER);
helloText.setText("Hello SWT and JFace!");
parent.pack();
return parent;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
HelloSWT_JFace awin = new HelloSWT_JFace();
awin.setBlockOnOpen(true);
awin.open();
Display.getCurrent().dispose();
}
}
The reject message I get from Eclipse is...
Could not find the main class: com.swtjface.ChTwo.HelloSWT_JFace.
Program will exit.
Here is the exception...
java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
You need at least 2 more jars to use JFace:
org.eclipse.equinox.common
org.eclipse.core.commands
See Using JFace outside the Eclipse platform for more details.
You need to add jar file for "org.eclipse.core.runtime.IProgressMonitor class"
Check this link.