Regarding JAR files.

Dear sir,
I have given the following coding as an assignment from my college.Please help me to solve it.I have to submit in few days. please reply me as soon as possible.
And assignment is:
h3. Problem Statement
You are trapped in a room full of zombies. Luckily the room is pitch black and, while the zombies can't see, you have night vision goggles. To get out though you will have to be careful, since bumping into a zombie is hazardous to your health.
More specifically, each zombie will have x and y coordinates between 0 and 99 inclusive. You start at (0,0). If you can get to (99,99), you can take an elevator to safety. You may not leave the room any other way. Get there as fast as you can!
You must implement a method move. This method takes two int[]s, zx and zy, giving the locations of all the zombies, along with ints x and y giving your location. Your method should return "S" to stand still, or "R", "L", "U", or "D" for the four cardinal directions, and "RU", "RD", "LU", or "LD" for the four diagonal directions: {noformat} LU U RU
L S R
LD D RD
{noformat}Moving right increases your x coordinate, while moving down increases your y coordinate.
After each of your moves, the zombies will all move randomly. Each zombie will chose a random direction (from the 9 including no move) and attempt to move in that direction. If a zombie wants to move outside of the box defined by (0,0)-(99,99) it will stay where it is instead. Note that while the initial locations of all the zombies are distinct, they will not stay that way -- multiple zombies may occupy the same location.
Each test case will be generated by first choosing a zombie density in [0.05,0.15]. All locations with x or y at least 5 will then contain one initial zombie with probability equal to the density.
The simulation will be run for a maximum of 10,000 time steps. You may run into zombies at most 10 times -- the 11th one will kill you. If you fail to reach the exit but you manage to stay alive for T time steps, your score will be T. If you make it to the exit at time T, your score will be 30000 - 2 * T plus 1000 per unused life. In other words, you have 10,000 steps to escape, and you get a bonus of 2 points for each time step you don't need to use. Your final score will simply be the average of your individual scores.
A simple is provided . To use it you need to write a program which communicates via standard IO. Your main method should first read in N, the number of zombies. For each call to move, you should read in N integers for zx, then N integers for zy, and finally two integers for x and y. You should simply output the move you would return. You can run it with something like: {noformat}java -jar Zombie.jar "java Zombie" -delay 1 -seed 1
{noformat}"java Zombie" is the executable, and should be replaced with whatever command will run your program. The -delay parameter sets the delay in milliseconds between moves. The -seed parameter specifies the random number generator seed (the examples are 1-10). There is also a -novis parameter which causes the simulation to be run with the visualization. Be careful not to output anything other than your moves to standard out. Standard error may be used for debugging purposes"
"CODING PROVIDED BY COLLEGE"
import java.util.*;
import javax.swing.*;
import java.io.*;
import java.security.*;
import java.awt.*;
import java.awt.event.*;
public class BrownianZombies extends JFrame{
int[] zx, zy;
int x, y;
int[] idx;
boolean[][] visited;
double p;
Random r;
int delay = 100;
boolean novis, history;
void generate(String seed){
try{
r = SecureRandom.getInstance("SHA1PRNG");
r.setSeed(Integer.parseInt(seed));
} catch (Exception e) {
e.printStackTrace();
int[] tx = new int[10000];
int[] ty = new int[10000];
idx = new int[10000];
visited = new boolean[100][100];
int ptr = 0;
p = r.nextDouble()*0.1+0.05;
for(int i = 0; i<idx.length; i++)idx[i] = i;
for(int i = 0; i<100; i++)for(int j = 0; j<100; j++){
if(i >= 5 || j >= 5)if(r.nextDouble() < p){
tx[ptr] = i;
ty[ptr] = j;
ptr++;
zx = new int[ptr];
zy = new int[ptr];
for(int i = 0 ;i<ptr; i++){
zx[i] = tx;
zy[i] = ty[i];
public void move(){
for(int i = 0; i<zx.length; i++){
int s = r.nextInt(i+1);
int t = idx[i];idx[i] = idx[s];idx[s] = t;
for(int i = 0; i<zx.length; i++){
int xx = zx[idx[i]] + r.nextInt(3) - 1;
int yy = zy[idx[i]] + r.nextInt(3) - 1;
if(xx < 100 && yy < 100 && xx >= 0 && yy >= 0){
zx[idx[i]] = xx;
zy[idx[i]] = yy;
int lives = 10;
int T;
public boolean ok(){
for(int i = 0; i<zx.length; i++)if(x == zx[i] && y == zy[i])lives--;
return lives >= 0;
public String checkData(String s){return "";}
public double runTest(String lt){
try{
int time = 10000;
generate(lt);
StringBuffer sb = new StringBuffer();
sb.append(zx.length).append('\n');
os.write(sb.toString().getBytes());
os.flush();
int score = 30000; T = 0;
if(history)visited[0][0] = true;
while((x != 99 || y != 99) && T < 10000){
T++;
sb.delete(0,sb.length());
sb.append(zx[0]);
for(int i = 1; i<zx.length; i++)
sb.append(' ').append(zx[i]);
sb.append('\n');
sb.append(zy[0]);
for(int i = 1; i<zy.length; i++)
sb.append(' ').append(zy[i]);
sb.append('\n').append(x).append(' ').append(y).append('\n');
os.write(sb.toString().getBytes());
os.flush();
String dir = input.next();
if(dir.equals("S")){
}else if(dir.equals("R")){
x++;
}else if(dir.equals("L")){
x--;
}else if(dir.equals("U")){
y--;
}else if(dir.equals("D")){
y++;
}else if(dir.equals("RU")){
x++;
y--;
}else if(dir.equals("LU")){
x--;
y--;
}else if(dir.equals("RD")){
x++;
y++;
}else if(dir.equals("LD")){
x--;
y++;
}else{
System.out.println("Invalid Direction: "+dir);
return 0;
if(x < 0)x = 0;
if(y < 0)y = 0;
if(x == 100)x = 99;
if(y == 100)y = 99;
if(!ok()){
System.out.println("Brains... Score = "+T);
return T;
move();
if(!ok()){
System.out.println("Brains... Score = "+T);
return T;
score -= 2;
if(!novis){
if(history)visited[x][y] = true;
repaint();
Thread.sleep(delay);
System.out.println("Score: "+(score + lives * 1000));
return score + (x != 99 || y != 99 ? 0 : lives * 1000);
}catch(Exception e){
e.printStackTrace();
return 0;
class Vis extends JPanel{
public void paint(Graphics g){
if(zx == null)return;
Graphics2D g2 = (Graphics2D)g;
g2.setColor(new Color(200,200,200));
g2.fillRect(0,0,getWidth(),getHeight());
Font f = new Font(g2.getFont().getName(),Font.PLAIN,20);
g2.setFont(f);
FontMetrics fm = g2.getFontMetrics();
int th = fm.getAscent();
int mul = Math.max(1,Math.min((getWidth()-1)/100,(getHeight()-1-2*th)/100));
int[][] cnt = new int[100][100];
for(int i = 0; i<zx.length; i++){
cnt[zx[i]][zy[i]]++;
for(int i = 0; i<100; i++){
for(int j = 0; j<100; j++){
if(cnt[i][j] == 1)g.setColor(Color.red);
else if(cnt[i][j] > 1)g.setColor(Color.magenta);
else if(visited[i][j])g.setColor(Color.cyan);
else g.setColor(Color.white);
if(i == x && j == y)g.setColor(Color.blue);
g.fillRect(mul*i+1,2*th+mul*j+1,mul,mul);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
String txt = "Moves Made: "+T;
g.setColor(Color.black);
g.drawString(txt,0,th);
txt = "Lives left : "+lives;
g.drawString(txt,0,2*th);
static Process pr;
static Scanner input;
static InputStream error;
static DataOutputStream os;
public static void main(String[] args) throws IOException{
BrownianZombies b = new BrownianZombies();
String exec = null;
String seed = "1";
for(int i = 0; i<args.length; i++){
if(args[i].equals("-delay")){
b.delay = Integer.parseInt(args[++i]);
}else if(args[i].equals("-seed")){
seed = args[++i];
}else if(args[i].equals("-novis")){
b.novis = true;
}else if(args[i].equals("-history")){
b.history = true;
}else{
exec = args[i];
if(exec == null){
System.out.println("Please enter an executable");
System.exit(1);
//for(int i = 0; i<b.zx.length; i++){
//System.out.println(i+" "+b.zx[i]+" "+b.zy[i]);
if(!b.novis){
b.add(b.new Vis());
b.setSize(450,450);
b.setVisible(true);
b.addWindowListener(new Closer());
pr = Runtime.getRuntime().exec(args[0]);
input = new Scanner(pr.getInputStream());
error = pr.getErrorStream();
os = new DataOutputStream(pr.getOutputStream());
new ErrorReader().start();
b.runTest(seed);
pr.destroy();
public String displayTestCase(String s){
generate(s);
return "p = "+p;
public double[] score(double[][] d){
double[] ret = new double[d.length];
for(int i = 0; i<ret.length; i++)
for(int j = 0; j<d[0].length; j++)
ret[i] += d[i][j];
return ret;
static class ErrorReader extends Thread{
public void run(){
try{
byte[] ch = new byte[50000];
int read;
while((read = error.read(ch)) > 0){
String s = new String(ch,0,read);
//System.out.println("err: "+s+" "+s.endsWith("\n"));
System.out.print(s);
System.out.println();
}catch(Exception e){
//System.err.println("Failed to read from stderr");
static class Closer implements WindowListener{
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowClosing(WindowEvent e){
pr.destroy();
System.exit(0);
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}

haytony, let me give you a word of advice. The more work you show, the more work the volunteers are often willing to give. For instance, if you've done a ton of research, wrote most of your own code but were stuck on specific points and posted this, the folks here will bend over backwards to lend you a strong hand to help you as much as possible.
If on the other hand, you simply post your entire assignment and don't show that you've done one speck of work, often we ignore you at best or ridicule you at worst.
C'mon, it's up to you. Step up to the plate and show us your work, and your worthiness for help. If you can prove yourself to be a hard-working studious type, then I personally will do all in my upmost to help you. If on the other hand you repeatedly spam these forums with pathetic attempts at getting others to do homework where there is absolutely no evidence that you have done a lick of work yourself, then I will ridicule, flame, and bother you to know end.
So which is it to be? Again, it's all up to you. Time to go to bat.

Similar Messages

  • Regarding jar file creation

    hi friends
    i created jar file using export in eclipse...Successfully created the jar file..but i want to include libarary files also with that jar..for example jdbc connector jar file with that jar..please help
    regards

    [Creating JAR file|http://java.sun.com/docs/books/tutorial/deployment/jar/build.html]

  • Regarding Jar file

    Hi,
    i need to download a jar file which would help me in accessing the methods present in IWD Bussiness Graphics Interface.
    Can you please let me help in these.
    Regards,
    Raju

    Hi,
    I can suggest a workaround that,  Use different ViewContainer UI elements for each Graph Type and Hide all the ViewContainers by setting the Visible Property to a node of type IWDVISIBLE. And in doinit method just set that node to VISIBLE_NONE.  So on seleting the graph type, capture the value and write if conditions and set the VISIBLE_TRUE for the View Container as required.  Like
    if(attr == bar)
    wdContext.node().setVisiAttr(VISIBLE_TRUE);
    the above code is an example. (just make changes to syntax)
    Revert me if you have any queries.
    Regards
    Raghu

  • Regarding jar file checkin in CRM ISA 6.0

    Hi,
    I want to checkin some java files in CRM ISA using NWDI but these java classes have dependency on some third party jars which i need to checkin as well.
    I am unable to find the location where i can checkin the jar files so that these files can be compiled and build without any error.
    Please reply ASAP.

    1) create an Extneral library DC
    2) import the JARs to the libraries folder of the External Library DC project
    3) Right-click on each of the JARs imported to the project and add them to the public part.
    This DC is now ready to be used as a build-time reference that will allow CBS to build the DC that will use the external libraries. Next, we have to create a new DC to hold the class files here are the steps:
    1) Create a new DC
    2) Create a new public part, selecting the "Can be packaged into other build results" option
    3) Rename the JARs as Zip files and extrct the full content (folders and class files) to your root folder
    4) Import the folders and files to the src/packages folder
    5) Expand the public part node that was created and select the "Entities" node, right-click it and choose Edit
    6) In the Entity Type list select the "Folder" option then in the selected entities tree pick each of the folders that you imported in step 5 (above)
    7) Now do a DC build and a DC deploy of the project
    Then check-in, activate, and release any activities you have associated with creating these two projects. In the DC perspective, refresh the Active DCs and Inactive DCs to ensure that both new DCs appear in the Active list. Now we have to setup the references to these DCs in our main Web Dynpro application. To do this, follow these steps:
    1) Open the respective perspective and right click the Used DCs node then choose "Add Used DC.."
    2) Pick the public part of the External Library DC that we created (first) and set it to have a Build Time dependency
    3) Again, right click the Used DCs node and choose "Add Used DC.." then choose the public part of the DC that we created to hold the classes  and give it a Run Time dependecy (weak) and click finish.
    4) Now, due to what I think is a bug. You must right click on the Web Dynpro "used DC" that you just added in the previous step, and set the run time dependency again (it seems to revert to the default values for some reason)
    5) Now do a DC build and a DC deploy on the "main" DC application.
    6) Check-in, activate, and release any activities associated with adding these references and then others on your team may use the classes in the external libraries within the Web Dynpro project.
    I think this will work this is working perfectly for webdynpr DC's
    Thanks and Regards
    shanto aloor

  • applet tag regarding JAR file

    Is there something wrong with the following applet declaration?
    <applet code = "Sheep2.class" archive="Sheep2.jar" width = 500 height = 300
    ALT="If you could run this applet, you'd see a sky, a field, and a moon.">
    Your browser is completely ignoring the <APPLET> tag!
    </applet>
    Works fine (it seems) on my Windows 98 computer with IE 6.0280, but does not work on the same computer when I access the page calling the applet using AOL's v.9 browser.
    I used HtmlConverter to convert the above to Extended version (covering all platforms), and still does not work with AOL's browser. HtmlConverter reported no errors, but now IE shows an error icon in its status bar when I access the page even offline.
    Other html files I converted using HtmlConverter work fine with AOL's browser. They don't have "archive" attribute.
    What could be going wrong? My guess is JAR file reference is causing problems.

    I did more Html Conversion today. I ran one file which didn't show any error mark in the status bar of IE through HtmlConverter. I ran the new file generated by HtmlConverter and an error icon appeared in the status bar of IE. My Java Console didn't show any message. So, it must be an error in the applet related info HtmlConverter generated was not 100% html compliant..
    BTW, I started speculating the cause of my applets not working on the computer of oen of my friends is simply that her Java Plug-in cannot handle Swing components' J classes.

  • Help regarding jar file

    hi all,
    i have jar file called com and i placed jar file in lib/ext
    in that i have two class say for ex. class a and class b.
    And class b extends class a.
    i am importing class b in some other class( in diffrent project)
    when i going to use the methods of class b it giving
    an error .......The type SQLPropertiesFN cannot be resolved. It is indirectly referenced from
    required .class files
    i don't no what the error is
    please help to solve this problem
    thanks in advance
    daya

    i have jar file called com and i placed jar file in lib/ext
    The type SQLPropertiesFN cannot be resolved. It is indirectly referenced from required .class files
    i don't no what the error is please help to solve this problem
    ...Where did you get that com.jar? Maybe there were also other jars or README file bundled with it?
    The error means that some class in "com.jar" needs another class that's not available, so probably you should add some other jar too...

  • Regarding the creation of common jar file ......!

    Hi All ,
    I need to create a new Jar file which consists of the generic code which we can use for connecting to the database. The class in the jar file should have methods like u201CExecuteSelectu201D. u201CExecuteInsertu201D, u201CExecuteDeleteu201D and u201CExecuteUpdateu201D.  which  should pass the required parameters to these methods so that they can execute the corresponding query. My  UDF should use this class file and call the methods above to run any SQL statements.
    any one having any idea about how to create the above requirements .....?
    Thanks in advance
    Aziz

    Hi,
    >> class in the jar file should have methods like u201CExecuteSelectu201D. u201CExecuteInsertu201D, u201CExecuteDeleteu201D and u201CExecuteUpdate
    For developing your requirement, you can use Eclipse or any other IDE which is supported for writing Java codes. Write the codes of your requirement in IDE and compile it. Make a .jar file of classes. and then create a new Imported archive and upload your .jar file. Then relevent  class has to be declared in the import statement. This way you can use your all classes in UDF.
    Regards
    Aashish Sinha

  • Help required regarding sending jar files using bluetooth

    I want to send jar file from Nokia 7610 (S60), or any other phone for that matter, to any other phone using bluetooth. The problem is that, when I look at the options available for the jar file (which is saved in the Inbox), the send option is not visible.
    I looked at the previous postings on this topic. Is it due to "Closed Content List" (CCL)??? What are the possible workarounds, other than using getResourceAsStream or some software like FExplorer???
    Also, this problem is not encountered in Sony Ericsson phones. Plz help regarding the same...

    Hi,
    You might wanna look take a look in the JSR 82 Specifications. There is a method like agent.startInquiry(); that starts a search for nearby BT devices. All you have to do is place each found device in an array of type Vector.
    It would have been easier if your code or a snippet of it was available to see what the problem was.
    Rambo.
    PS: A client application application starts a connection on a server application. Where you put them is up to you.

  • Regarding recreating jar file

    I am new to ejb.
    i used jcreator to develop session bean.i created jar file after going to command prompt.and deployed it using weblogic builder and server.it worked fine for me.
    But now i want to add more functions to ejb.So i need to create jar file again and its v long procedure.
    So can anyone guide me proper approach to save time.
    Any reply will be highly appreciated
    thanks,

    The best possible way to speed up the process of ur development is to write a small build (ant) script......which does everything for u. The task seems tedious if manually done......writing ANT script is not a difficult task......U can try this...............
    For ANT u just visit www.jakarta.apache.org
    I felt it is the best tool for developers............if they don't use any IDE's
    Hope this helps and if u need further help .......get back.......

  • How to modify a specific class in jar file ?

    I've downloaded a jar file for applet, the jar file works fine... but when I extract a specific class file from the jar file and just recompie it from my IDE (Eclipse) without even making any change and then compress again jar class files including the new modified class file instead of the old one (without any modifications to other classes)... then I get
    (NoSuchMethodError ) exception whenever methods of other classes are invoked from within the modified class !!
    ...The manifist file of the jar file reads the following line
    Created-By: 1.4.0_01 (Sun Microsystems Inc.)
    I thought it means that jar class files were built using JDK 1.4.0_01 ...I used JDK 1.5.0_01 in my IDE...
    I thought JRE incompatiblity was the reason of the problem so I downloaded JRE 1.4.0_01 and used it to build this class file... but i got the same exception..
    so what is the main reason of the problem ? ...should I make changes to IDX files accompanying applet jar files ??
    If no, then how can I overcome this problem and be able to change and rebuild a specific class from this jar file ?
    (I cannot rebuild all classes in jar because there are errors I cannot resolve !!)

    Could you please clarify: do you want to run your project or a project from an independent jar?
    In the first case just select Run Project from the project context menu or select a class with main method and click Run File in the class context menu.
    Regarding the second case:
    - I don't think there is such a feature in the IDE (running third party jars is not an IDE function). Could you explain why you need this?

  • NOT WORKING: Putting a jar file requiring native library in bootclasspath

    Hi,
    I put my own jar file into the bootclasspath like this:
    java -Xbootclasspath/p:myboot.jar TestClass
    Some classes in the jar require a native library. For JVM 1.3 on Solaris, I put the native library in $JAVA_HOME/jre/lib/sparc and everything works just fine.
    However, when I try the same thing on JVM1.4, I got the following error when my class containing the native methods is called:
    Failed to load the native library: myboot_native
    java.lang.UnsatisfiedLinkError: no myboot_native in java.library.path
    I tried to put that native library in several different directories in jre/lib but still had no luck.
    Is there anybody know the solution? Does JVM1.4 allow me to put a custom jar file that requires a native library in the bootclasspath?
    Regards,
    Eman

    Well is your file in a directory included in the java.library.path environement variable. I use java on windows but I have to add the directory where my native library is to the path variable (not classpath) in order to avoid the error you get.

  • Application works in jdeveloper but not as standalone jar file

    Hi All
    We have developed an application using BI Publisher APIs,it works as expected through JDevelper,however when I try to deploy it to a jar file a run it through command line it gives me No class found exception for
    javax/xml/rpc/Service class factory.. thinking that the class is not present.I have extracted the jar file but could find the class file in the expected directory........anyhelp would greatly be appreciated.
    Regards
    Venkatesh

    Hi Venkatesh,
    Few questions.
    1. What is your JDeveloper version? (Always better to post your JDev version along with the question, which would help us to help you better).
    2. Did you try adding webserviceclient.jar to the classpath? (Search in your JDev installation directory for the location of this jar file).
    -Arun

  • Executing a jar file from an arbitrary folder

    I got a small problem in detemining the path of my application's jar file. I am starting the application by executing a batch, lets say MyApp.bat (using it on windows and unix), this batch file consists of one line 'java -jar MyApp.jar', MyApp.jar being in the same folder.
    Now lets say MyApp.bat and MyApp.jar are in folder 'A' and my current working directory is a parallel folder 'B', so I can invoke the batch file from there(!) by executing '../A/MyApp.bat'. But now the VM tries to find MyApp in the current working directory which is still 'B' and not 'A'. A simple solution would be to use a script which determines the directory of MyApp.jar and include the generated path in the call to the VM (I didn't try yet, but I guess this will awkward doing it on windows)
    Since I don't think I am the first person executing a java program via a script from an arbitrary folder in a file system, I hoped that there might be a more elegant way. Unfortunately I couldn't find another solution yet.
    Regards,
    Stefan

    In MyApp.bat your line should read (NT/2K/XP/2003/Vista):java -jar "%~dp0MyApp.jar"Regards

  • Where i Put my swing application jar file in jboss

    Hi experts...
    I develope swing application and convert it into jar file....I know jnlp deployment using tomcat..In tomcat i
    put my appcation.jar in webapps/root folder...This is not similar in jboss..I dont know where i put my applcation.jar in jboss.If any body know the idea please let me know..

    Hi
    You have to put your jar file in
    server/default/deploy
    Regards
    M Fazal Ur Rehman

  • Jar file is not executing

    hi all,
    i was creating a jar excutable, when i was trying to execute it by double clicking on it(its placed in the desktop), open with dialog box is coming. could u plz help me out??
    here what i've done.. in the manifest file i've entered
    Manifest-Version: 1.0
    Main-Class: Class2Jarand to create the jar file i've given the command
    jar cmf manifest.mf max.jar Class2Jar.classthankx & regards,
    max

    open with dialog box is comingLooks like a broken file association. Try re-installing the Java runtime to have Jars associated to it again.

Maybe you are looking for

  • New Mini - DVI to component video?

    I'm thinking of purchasing a new Intel Mini but want to connect it to my TV. My current Intel/Beyond TV box uses S-Video and is less than optimal. My TV is: Sony VEGA KV-32XBR450 HD/DVD In ports - 1080i/480p/480i - Y,Pb,Pr component video jacks

  • Default mail client (CR XI)

    Hello, we have the following problem: We have a application using Crystal Reports XI. It's a C++ application and not a .net, but i think that doesn't matter.  One customer using this application has Lotus Notes and NOT Microsoft Outlook as mail clien

  • Remote access via internet to another macbook

    I would like to access my moms computer when she needs help sometimes via the internet. We both have Macbooks and high speed internet. Before I move away I can install whatever is necessary on her computer. Then if she has computer problems (as she o

  • Unstable Operating System

    Is it me, or is this iOS5 really unstable? I mean, there are quite a few apps that are now constantly force-closing on my iPad (and iPod as well). Now I can understand that some third party apps experience some instability issues with a new OS. But s

  • Tidy can balance open tag missing

    Hi, I am using tidy.parser for balance missing tag. Tidy can balance end tab missing. But in my case i want to balance user define open tag missing. Like that: <p>@amp_nbsp</p> <p style="margin-bottom: 0in; line-height: 150%">      <font face="Arial,