Re: java.lang.InstantiationException
fnl <[email protected]>
| Newsgroups | gmane.comp.java.robocode |
|---|---|
| Message-ID | <[email protected]> |
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
Den fredag den 31. oktober 2014 06.16.44 UTC+1 skrev [email protected]:
>
> 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?
>
> 2014년 10월 27일 월요일 오전 6시 17분 33초 UTC+9, 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
>>
>>
>> Den fredag den 24. oktober 2014 07.05.21 UTC+2 skrev [email protected]:
>>>
>>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.