Discussion:
java.lang.InstantiationException
c***@gmail.com
2014-10-24 05:05:21 UTC
Permalink
Hello,

I had tried to execute test robot after Eclipse project with example
code included in robocode-1.9.2.3-setup.jar
But when executed, it generate error with
java.lang.InstantiationException.
I use 1.7 java version and I am java beginner.

Please tell me solution if you know....
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
fnl
2014-10-26 21:17:32 UTC
Permalink
Hi, :-)
Can you tell me how to reproduce the problem?
You mention "test robot". Which robot is it that causes the issue?

Robocode should work on both Java 7 (1.7) and Java 8. Are you using OpenJDK
or Oracle JDK?

Which system are you running on?

Cheers,
- Flemming
Post by c***@gmail.com
Hello,
I had tried to execute test robot after Eclipse project with example
code included in robocode-1.9.2.3-setup.jar
But when executed, it generate error with
java.lang.InstantiationException.
I use 1.7 java version and I am java beginner.
Please tell me solution if you know....
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
c***@gmail.com
2014-10-31 05:16:44 UTC
Permalink
Dear Flemming,

I make a code below

public class harueRobot extends AdvancedRobot {
public harueRobot() {}
public void run () {
while (true) {
}
}
}

And after compiling a code, I try to battle robot in robocode tool

And it generate error below

Round 1 initializing..
Let the games begin!
java.lang.InstantiationException: yongjin2712choi.harueRobot
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:325)
at
net.sf.robocode.host.security.RobotClassLoader.createRobotInstance(RobotClassLoader.java:256)
at
net.sf.robocode.host.proxies.HostingRobotProxy.loadRobotRound(HostingRobotProxy.java:171)
at
net.sf.robocode.host.proxies.HostingRobotProxy.run(HostingRobotProxy.java:210)
at net.sf.robocode.host.proxies.BasicRobotProxy.run(BasicRobotProxy.java:44)
at java.lang.Thread.run(Thread.java:722)

.yongjin2712choi.harueRobot could not be started or loaded. This robot has
been banned and will not be allowed to participate in battles.

Waiting for robot yongjin2712choi.harueRobot to stop thread TimerQueue
Robot yongjin2712choi.harueRobot is not stopping. Forcing a stop.

I don't know a reason.

Do you know why does it generate error?
Post by fnl
Hi, :-)
Can you tell me how to reproduce the problem?
You mention "test robot". Which robot is it that causes the issue?
Robocode should work on both Java 7 (1.7) and Java 8. Are you using
OpenJDK or Oracle JDK?
Which system are you running on?
Cheers,
- Flemming
Post by c***@gmail.com
Hello,
I had tried to execute test robot after Eclipse project with example
code included in robocode-1.9.2.3-setup.jar
But when executed, it generate error with
java.lang.InstantiationException.
I use 1.7 java version and I am java beginner.
Please tell me solution if you know....
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
fnl
2014-10-31 22:23:05 UTC
Permalink
Hi cyj2712,

First of all, I recommend that you use a big capital letter for the class
name, which is a code convention in Java.
So you should rename the class to HarueRobot instead of harueRobot. You
need to do the same thing for the constructor as well.
Note, that you don't need a default constructor when creating a robot in
Robocode. The run method is the main method.

Another problem with your robot is within the run() method in the infinite
while-loop.
For each turn, the robot must execute. For an AdvancedRobot, you could do
this by calling execute() within the while-loop.

So your source code would look like this:

package yongjin2712choi;

import robocode.AdvancedRobot;

public class HarueRobot extends AdvancedRobot {

public void run () {
while (true) {
execute();
}
}
}

I hope this helps? :-)

Best regards,
- Flemming
Post by c***@gmail.com
Dear Flemming,
I make a code below
public class harueRobot extends AdvancedRobot {
public harueRobot() {}
public void run () {
while (true) {
}
}
}
And after compiling a code, I try to battle robot in robocode tool
And it generate error below
Round 1 initializing..
Let the games begin!
java.lang.InstantiationException: yongjin2712choi.harueRobot
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:325)
at
net.sf.robocode.host.security.RobotClassLoader.createRobotInstance(RobotClassLoader.java:256)
at
net.sf.robocode.host.proxies.HostingRobotProxy.loadRobotRound(HostingRobotProxy.java:171)
at
net.sf.robocode.host.proxies.HostingRobotProxy.run(HostingRobotProxy.java:210)
at
net.sf.robocode.host.proxies.BasicRobotProxy.run(BasicRobotProxy.java:44)
at java.lang.Thread.run(Thread.java:722)
.yongjin2712choi.harueRobot could not be started or loaded. This robot has
been banned and will not be allowed to participate in battles.
Waiting for robot yongjin2712choi.harueRobot to stop thread TimerQueue
Robot yongjin2712choi.harueRobot is not stopping. Forcing a stop.
I don't know a reason.
Do you know why does it generate error?
Post by fnl
Hi, :-)
Can you tell me how to reproduce the problem?
You mention "test robot". Which robot is it that causes the issue?
Robocode should work on both Java 7 (1.7) and Java 8. Are you using
OpenJDK or Oracle JDK?
Which system are you running on?
Cheers,
- Flemming
Post by c***@gmail.com
Hello,
I had tried to execute test robot after Eclipse project with example
code included in robocode-1.9.2.3-setup.jar
But when executed, it generate error with
java.lang.InstantiationException.
I use 1.7 java version and I am java beginner.
Please tell me solution if you know....
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...