Help with 'AI' in Java
Hello,
I am very new to Java and am stuck on 1 final part of a piece of work I am completing. I have written a MIDlet game (similiar to noughts and crosses) where each player takes it in turn to click a button until one of the players has reached the win state. I now however need to adapt this so that it is 1 human player against 1 computer player. I don't need to provided the computer player with any decision making logic (as of yet), but would just like it to randomly select a button each time it is it's turn.
for buttons, I am using item commands placed on top of StringItems and given them the BUTTON appearence in their properties.
I have already declared a random variable which generates a random number between 1-10 (inclusive), but am unsure how to tell the computer to (for example) select button 5 if a 5 is generated.
As I said I have this working for 2 human players, and am happy to provide source code of this (although it will probably loook very poor)
Any help or hints would be greatly appreciated.
Regards,
nosaj_ccfc
Project Moon,
I do not have the StringItems declared in either a list or an array, I have actions assigned to them depending on whether they have been selected by either player. I have provided an example of one below
if (item == Word1) {
if (command == itemCommand1) {
// Insert pre-action code here
// Do nothing
if(PlayerTurn == 1)
WordTableLayout.setValue(0,Player1Row,Word1.getText());
CurrentPlayer.setLabel("Player 2");
PlayerTurn = 2;
Player1Row++;
P1WinComboA++;
P1WinComboB++;
else if(PlayerTurn == 2)
WordTableLayout.setValue(1,Player2Row,Word1.getText());
CurrentPlayer.setLabel("Player 1");
PlayerTurn = 1;
Player2Row++;
P2WinComboA++;
P2WinComboB++;
Word1.removeCommand(itemCommand1);
}
Similar Messages
-
Looking for Help with Hyperion to JAVA
I am looking for help with connecting Hyperion to Java. We are in Maryland but would be willing to work out something for remote consulting. If you have experience with connecting web services, hyperion, and Java and would be interested in about 80 hours of consulting please contact me at:[email protected] x4846
Hi,
From your description, you want to achieve the following goal:
Configure Exchange to filter the attachments if the size is over 10 MB and store it in a public folder, and then forward the email to Salesforce.
Based on my knowledge, I'm afraid that it can't be achieved. Exchange can filter messages with attachments, but it couldn't store these attachments on public folder automatically. Also, I don't see any transport rule can do it.
Hope my clarification is helpful.
Best regards,
Amy Wang
TechNet Community Support -
I've only got ONE handful of hair left.
I'm trying to build a series of dropdown boxes; a day dropdown (Mon, Tue, Wed...), a month dropdown (Jan, Feb, Mar...), a year dropdown, hour dropdown, minute dropdown, and an am/pm dropdown.
I think I want to build my dropdowns using "for" loops something like this:
for (i=0;i<12;i++) {
myStringBuffer.append("<option>" + [someUnknownFunctionThatReturnsTheFirstThreeLettersOfTheMonth(i)] + "</option>")
I've been trying to mix up various combinations of Date objects (most date functions seem to be depreciated), Calendar Objects, DateFormat Objects and SimpleDateFormat Objects but nothing seems to want to perform the function that I need.
I've had iffy success creating a calendar object, setting the Month to "i", using the getTime function to return a Date object which I can then pass to the SimpleDateFormat object using the .format(Date) function, after setting the pattern to "EEE", but it seems like just an incredibly complicated way to do what ought to be a simple function...i.e. convert a number 0-11 (or 1-12, I'm not picky) into the name of a stinking Month! Arrgh.
If anyone can help, I thank you.I've done that before, so i'll share it with you.
import java.text.SimpleDateFormat;
import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Date;
public String createListOfMonth(String pName) {
StringBuffer sbMonth = new StringBuffer();
DateFormatSymbols fm = new DateFormatSymbols();
String[] arrMonth = fm.getMonths();
sbMonth.append("<select name=\"" + pName + "\">");
sbMonth.append(" <option value=\"\">Month</option>\n");
for (int i=0; i<arrMonth.length; i++) {
if (!arrMonth.trim().equals("")) {
String sValue = "0000" + (i + 1);
sValue = sValue.substring(sValue.length() - 2);
sbMonth.append(" <option value=\"" + sValue + "\">" + arrMonth[i] + "</option>\n");
sbMonth.append("</select>");
return (sbMonth.toString());
You can manipulate the symbol (either for months, days) using different locale. You can see the API for java.text.DateFormatSymbols in Java2 SE.
Regards,
Hariyanto -
Im DROWNING! need help with a simple java assignment! plz someone help me!
i need help with my java assignment, with validating a sin number. easy for must who know java. im drowning... please help!
You will need to store each digit of the social insurance number in a field of its own. To validate the entry you will:
1. Multiply the 2nd, 4th, 6th and 8th digit by 2.
2. If the product of any of the four multiplications result in a value greater than 9, add the two resulting digits together to yield a single-digit response. For example 6 * 2 = 12, so you would add the 1 and the 2 to get a result of 3.
3. Add these four calculated values together, along with the 1st, 3rd, 5th, and 7th digits of the original number.
4. Subtract this sum from the next highest multiple of 10.
5. The difference should be equal to the 9th digit, which is considered the check digit.
Example of validating S.I.N. 765932546
1st digit 7
2nd digit (6*2 =12 1+2=) 3
3rd digit 5
4th digit (9*2 = 18 1+8 =) 9
5th digit 3
6th digit (2*2 = 4) 4
7th digit 5
8th digit (4*2 = 8) 8
Total 44 next multiple of 10 is 50
50-44 = 6 which is the 9th digit
Therefore the S.I.N. 765932546 is Valid
********* SIN Validation *********
Welcome - Please enter the first number: 120406780
Second digit value multiplied by 2 4
Fourth digit value multiplied by 2 8
Sixth digit value multiplied by 2 12
Eighth digit value multiplied by 2 16
Value derived from 6th digit 3
Value derived from 8th digit 7
The total is 30
Calculated digit is 10
Check digit must be zero because calculated value is 10
The SIN 120406780 is Valid
this is my assignemtn this is what i have! i dont know where to start! please help me!
/* File: sinnumber.java
Author: Ashley
Date: October 2006
Purpose: Lab1
import java.util.Scanner;
public class Lab1
public static void main(String[] args)
Scanner input = new Scanner(System.in);
int sin = 0;
int number0, number1, number2, number3, number4, number5, number6, number7, number8;
int count = 0;
int second, fourth, sixth, eighth;
System.out.print("\t\n**********************************");
System.out.print("\t\n**********SIN Validation**********");
System.out.print("\t\n**********************************");
System.out.println("\t\nPlease enter the First sin number: ");
sin = input.nextInt();
count = int.length(sin);
if (count > 8 || count < 8)
System.out.print("Valid: ");
} -
Need help with long term Java problems
I've been having problems with Java on my computer for about a year now, and I'm hoping that someone here can help me out.
Java used to work fine on the computer when I first got it (a Dell laptop) and I hadn't installed anything myself. But then one day it stopped loading Java applets, and hasn't worked since. By this, I mean that I get the little colorful symbol in a box when I try to play Yahoo games, use the http://www.jigzone.com site, go to chat rooms, etc. Java menus on websites like http://www.hartattack.tv used to work still, but lately they've been giving me that symbol too.
I've tried downloading a newer version of Java, but nothing I do seems to work, and I don't know of anything I did to trigger it not working. I'm hoping there's a simple solution to this, and I'm just dumb.
Thanks.This might be way off, but it's something that's tripped me up in the past:
If you are using Sun's Java plugin, the first time you go to a site that has a particular Java applet, you may be asked to approve/reject a security request.
If you have clicked on any other windows while the request is first being loaded (which can take some time, because this is swing based), then the security dialog box does not pop to the top of the window stack, and doesn't add an entry into the task bar.
It appears that Java just doesn't work, but it's actually waiting for you to click "Yes". You can check this by hitting alt-tab and seeing if the Java coffee cup icon is one of the options.
- K -
Need help with running a Java program on Linux
I am trying to get a Java program to run on a Linux machine. The program is actually meant for a Mac computer. I want to see if someone with Java experience can help me determine what is causing the program to stall. I was successful in getting it installed on my Linux machine and to partially run.
The program is an interface to a database. I get the login screen to appear, but then once I enter my information and hit enter the rest of the program never shows, however, it does appear to connect in the background.
Here is the error when I launch the .jar file from the command screen:
Exception in thread "main" java.lang.IllegalArgumentException: illegal component position
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
I am not a programmer and I am hoping this will make some sense to someone. Any help in resolving this is greatly appreciated!Well, without knowing a little bit about programming, and how to run your debugger, I don't think you're going to fix it. The IllegalArgumentException is saying that some call does not like what it's getting. So you'll have to go in an refactor at least that part of the code.
-
Hi, I'm trying to develop an application on a Machintosh OSX 10.2.8 machine.
I'm having a herrendous time trying to get quicktime to work on it.
I've somehow managed t oget 1.3.1 and QTJava.jar to work together but now i need encryption, however that requires 1.4+
Now 1.4.1 doesnt work with quicktime
I've downloaded the latest software upgrades but Ive got no idea how to set up quicktime to work with java 1.4.1
Now to add on top of that mac reports it can use AES encryption. this is from source code ripped striaght from this website.
But first and foremost can anyone, annyonee help me out with setting up 1.4.1 with quicktime?
Thank youIf you need encryption with Java 1.3.1, download the JCE from either Sun (http://java.sun.com/products/jce/) or Bouncy Castle (http://www.bouncycastle.org/).
Cheers,
--Arnout -
Hi.
I'll have this question, and can't find the right answer...
Suppose is this site called xyz.com and you need to register to be a member
For simplicity member log-in page is simple...contains only login and password fields(Submit too) in HTML code:
<html>
<body>
<form name="input" action="html_form_action.asp" method="get">
User ID: <input type="text" name="ID" /><br />
Password: <input type="password" name="pwd" /><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>Will I be able to build a Java application witch will:
1-Send me to this web-page
2-Place my chosen id and password in the right place
3-"Press" Submit button.
So I open this Java Swing application , and Go button will send me to the members page of my xyz.com page.
Thank you for the help.altisw5 wrote:
Go button will send me to the members page of my xyz.com page.It depends on what you mean by "send me".
If you mean access data on the members page through your program, yes.
If you mean open a browser window to that page, I guess doable but might be tricky (with Robot and stuff).
If you mean physically send you on the internet, no. -
I need some help with sound in Java
hi, i`m new to java. i`m having a through problems with a program i`m writing. i`ve added a song to an applet but it does not play. The code for this is:
private AudioClip music;
music = getAudioClip(
getDocumentBase(), "titantic.wav" );
Can some 1 tell me is that the write code. please help.2 things.
1. You must also send a command to play the music file.
2. I'm not certain, but I think that you can only load .au files this way. -
I'm fairly inexperienced with java, but I'm hopeful someone here won't mind helping.
I am using netbeans and have a project to let a user upload files or scan them in with a usb scanner. I've imported icepdf to the libraries and referenced it in the jnlp file and it worked fine. I did the same with jai_windows-i586.jar and I get this error when trying to upload
Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: com/sun/media/jai/codec/SeekableStream
Caused by: java.lang.ClassNotFoundException: com.sun.media.jai.codec.SeekableStream
I expanded the jar file and found it contained an exe. jai-1_1_3-lib-windows.i586.jre.exe. I found that if I run that exe [(found here)|http://download.java.net/media/jai/builds/release/1_1_3/] on any pc locally, I will not get the errors on that pc.
Am I referencing it incorrectly?
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="1024m" />
<jar href="ScanAreaUI.jar" main="true" />
<jar href="icepdf-core.jar"/>
<jar href="jai_windows-i586.jar"/>
<nativelib href="JTwain-Native.jar" />
</resources>
Do I need to make the applet install the exe located in the jar? I've tried to find information on how to do that without much luck so far.
Thanks for any advice/help.If it's not finding your "exe" file, then you have an OS path problem. You can either change your path variable in Windows or you can move that "exe" to a location where you already have a path defined. You do realize that when you use features of JAI that are not incorporated in to the JDK, you'll have to have the JAI package loaded on every machine you ever want to run your project.
-
I periodically get a stuck Execute thread on my Weblogic 8.15 server
during a call to a Stateless Session Bean. When I do thread dumps, the
thread is always stuck in the same place (in
java.lang.String.equals(String.java:619) or in the call immediately above it
java.util.LinkedList.indexOf(LinkedList.java:397)). Even though the thread
dump indicates that the thread is in a runnable state, if I do multiple
thread dumps over a period of time, the stack trace always indicates that
the thread is in the same place. The thread remains stuck until Weblogic is
restarted. Other client applictions can make session bean calls, but each
stuck thread seems to still take up lots of CPU time. I have let the stuck
threads run overnight, and the stack trace from the thread dump always shows
them executing the same String/LinkedList code. In each case, our code is
trying to iterate over a collection
Does anybody know what could cause this problem, and how to fix it? I get
StuckThreadMaxTime errors in the log:
####<Dec 4, 2005 10:47:25 AM EST> <Error> <WebLogicServer> <nybill>
<myserver> <weblogic.health.CoreHealthMonitor> <<WLS Kernel>> <>
<BEA-000337> <ExecuteThread: '4' for queue: 'weblogic.kernel.Default' has
been busy for "1,263" seconds working on the request
"ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl", which
is more than the configured time (StuckThreadMaxTime) of "1,200" seconds.>
Here are some stack traces from different thread dumps (I have the full
thread dumps if necessary):
"ExecuteThread: '10' for queue: 'weblogic.kernel.Default'" daemon prio=5
tid=0x7720eb98 nid=0xd68 runnable [571f000..571fdb0]
at java.lang.String.equals(String.java:619)
at java.util.LinkedList.indexOf(LinkedList.java:398)
at java.util.LinkedList.contains(LinkedList.java:176)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getDailyCallSummary(XMLBillCr
eation.java:1992)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getGraphs(XMLBillCreation.jav
a:1931)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getLocations(XMLBillCreation.
java:2618)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.createXMLBill(XMLBillCreation
.java:236)
at
ncss.billing.ejb.billAdmin.session.BillAdminSessionEJB.getBillAsXml(BillAdmi
nSessionEJB.java:341)
at
ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl.getBillAsX
ml(BillAdminSession_uli3xb_EOImpl.java:100)
at
ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl_WLSkel.inv
oke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:108)
at
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
t.java:363)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
0)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
"ExecuteThread: '22' for queue: 'weblogic.kernel.Default'" daemon prio=5
tid=0x772538d0 nid=0xe24 runnable [497f000..4fdb0]
at java.lang.String.equals(String.java:619)
at java.util.LinkedList.indexOf(LinkedList.java:398)
at java.util.LinkedList.contains(LinkedList.java:176)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getMostExpensiveOrLongestCall
s(XMLBillCreation.java:1892)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReport(XMLBillCreati
on.java:1798)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReports(XMLBillCreat
ion.java:1751)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getLocations(XMLBillCreation.
java:2612)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.createXMLBill(XMLBillCreation
.java:236)
at
ncss.billing.ejb.billAdmin.session.BillAdminSessionEJB.getBillAsXml(BillAdmi
nSessionEJB.java:341)
at
ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl.getBillAsX
ml(BillAdminSession_uli3xb_EOIm.java:100)
at
ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl_WLSkel.inv
oke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:108)
at
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
t.java:363)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
0)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
"ExecuteThread: '21' for queue: 'weblogic.kernel.Default'" daemon prio=5
tid=0x76afb060 nid=0x498 runnable [48af000..48fdb0]
at java.lang.String.equals(String.java:619)
at java.util.LinkedList.indexOf(LinkedList.java:398)
at java.util.LinkedList.contains(LinkedList.java:176)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getMostFrequentlyCalledNumber
sOrCitiesReport(XMLBillCreation.java:1839)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReport(XMLBillCreati
on.java:1772)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getTopTenReports(XMLBillCreat
ion.java:1743)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.getLocations(XMLBillCreation.
java:2612)
at
ncss.billing.broadviewBill.xml.XMLBillCreation.createXMLBill(XMLBillCreation
.java:236)
at
ncss.billing.ejb.billAdmin.session.BillAdminSessionEJB.getBillAsXml(BillAdmi
nSessionEJB.java:341)
at
ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl.getBillAsX
ml(BillAdminSession_uli3xb_EOImp.java:100)
at
ncss.billing.ejb.billAdmin.session.BillAdminSession_uli3xb_EOImpl_WLSkel.inv
oke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:108)
at
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec
t.java:363)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
0)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
The code in LinkedList that it seems to be executing is the following:
Line#
397 for (Entry e = header.next; e != header; e = e.next) {
398 if (o.equals(e.element))
399 return index;
400 index++;
401 }
I am running Weblogic 8.15 on Windows 2000.
Thanks for any help,
- Donnjb7ty wrote:
I suggest dropping that example program and concentrating on reading a book on Java such as 'Head First in Java'. Otherwise, you will spend a lot of time trying to get something to work and gain little value from it.Likewise... Jumping into reflections before you can [read a stack-trace|http://www.0xcafefeed.com/2004/06/of-thread-dumps-and-stack-traces/] is like signing up a toddler for the New York Marathon... it's probably simply beyond your skill level... so step back... go read a book, do some tutorials, get your head around just the process of the designing, writing, compiling, running, and debugging java programs... and what the different diagnostics mean... Then, equipped with your nose-clip and your trusty stone ;-) you contemplate leaping into the deep end ;-)
Cheers. Keith. -
hi there, i'm a computer tech graduate student,
i'm making an http server as a work for a course. With need to implement CGI also. The suggested language was C++ or pain C. But i wanted to implement it on java. The problem is that so far i haven't figured out how can i divert the standart input and output to pipes, and interact with aplication written in other languages.
in C we, create pipes, we divert the standart input/output to the recently created pipes, and then we use a system call "execle" to call it.
I thank you in advance,If you want to pipe data to the standard input stream of a process that your Java application spawns, use Runtime.exec() to spawn the process. Runtime.exec() returns a Process representing the new process. Then use the getOutputStream() method to get an OutputStream. Anything you write to that OutputStream will be piped directly to the standard input stream of the process (that's right, getOutputStream() for the standard input stream, don't get confused).
Additionally, any data that the child process writes to it's standard output stream can be read through the InputStream returned by the getInputStream() method of Process.
Hope that helps,
Jason -
I need to replace some content in a file . Can some one tell me if we can append or replace only a part of the content in files using Java?
Right now I am using Stringtokenizer, break the file into tokens and put them in a buffer, append the required data and then write to a file. But this seems very crude way of doing it and the output is not as I wanted it.
Please help,
Thanks"Random" updates to files are possible, but the problem lies when part of a file changes size, with the need to move the rest of it up or down. In general, when part of the file might change size, it's a lot easier all round to create a new version of the file and rename.
-
hi
i am new to java .I write my program in myeclipse4.0 while running the code it gives error dialogbox like javavirtualMachine says that fatal error came so program is exited.after that ArrayIndexOutOfBoundException is came. I am unable to understand this error.can any one help me.
code is as follows
import java.lang.reflect.*;
public class RefTest1
public static void Listsuperclass1(String name)
try
Class c = Class.forName(name);
Class sc = c.getSuperclass();
String cname = c.getName();
String sname = sc.getName();
System.out.println("\t\t"+cname+"extends"+sname);
catch(ClassNotFoundException cnf)
cnf.printStackTrace();
catch(Exception e)
e.printStackTrace();
public static void main(String[] args)
Listsuperclass1(args[0]);
Thank younjb7ty wrote:
I suggest dropping that example program and concentrating on reading a book on Java such as 'Head First in Java'. Otherwise, you will spend a lot of time trying to get something to work and gain little value from it.Likewise... Jumping into reflections before you can [read a stack-trace|http://www.0xcafefeed.com/2004/06/of-thread-dumps-and-stack-traces/] is like signing up a toddler for the New York Marathon... it's probably simply beyond your skill level... so step back... go read a book, do some tutorials, get your head around just the process of the designing, writing, compiling, running, and debugging java programs... and what the different diagnostics mean... Then, equipped with your nose-clip and your trusty stone ;-) you contemplate leaping into the deep end ;-)
Cheers. Keith. -
Hi All,
I am currently stuck in a program that I am coding. I have written a java program that should execute a system command and capture the output of the command.
Here is my code:
String boxname="";
String box = new CmdExec().run("echo $__box_name");
boxname = (box[box.length-1]);
System.out.println("BoxName2:"+boxname+"\n");
Here is the output:
BoxName2:$__box_name
The problem I am having is that the "echo $__box_name" command returns $__box_name, and not the acutal value of the $__box_name...which I have set to be "testbox." The problem is the command line is taking $__box_name as text..and that's not what I want.
I have the code working another way, but it is impractical. In the second version I have a script named get_name with two lines in it:
#!/usr/bin/ksh
echo $__box_name
In my java code calls the script with the following changes:
String boxname="";
String[] box = new CmdExec().run("./get_name");
boxname = (box[box.length-1]);
This returns the value of $__box_name which is "testbox," and not the text "$__box_name." On the other hand, I don't want to have a separate script just to display one simple value. I don't know what the problem with the "echo $__box_name"command is, but I'm assuming that the space between the command may be the problem. I tried running the java program with "hostname" instead of the "echo $__box_name" and it returned the actual server name. Is there a way other than having a separate script, of combining the "echo $__box_name" command
into a single execution...say "getbox" (so i can just run String[] box = new CmdExec().run("getbox")) ?? If anyone can help, I'd appreciate it. I just don't understand how something so simple can make me pull my hair out. Any feedback would be much appreciated. Please put me out of my misery..Thanks.
BrianThe command you just gave me returns nothing. I also tried usin "ksh echo $__box_name"...and modified it with the backlash "`", backslash "\", and single quote "'"...nothing has seemed to work. The closest I got was getting an integer as a return value. Your piece of code seems to be pretty close. I am not quite sure what that line means...could you please let me know what each part of the code means?
/bin/sh -c echo $__box_name
Thanks
Brian
Maybe you are looking for
-
I have a macbook pro version 10.7.5 and my mailbox will not open at all and comes up with a quit message even though it is not open. how can i get into my account. it works on my iPhone and i have internet and all other functions working on my comput
-
What class should be imported to resolve the error
Dear all, would you please tell me that what class should i import to resolve the error for PreparedStatement. plz mention the import statement Error(437,13): class PreparedStatement not found in class oracle.apps.ak.cacheoffice.server.CacheOfficeAMI
-
Final Cut (& other app) direction
Greetings. I'm a longtime "lurker", first time discussion participant... appreciate all the knowledge you guys share here. Two part question for you. The first to help me with a current situation, the second for long-term direction. 1.) After editing
-
Hi, im trying to hook my Kinyo d565 speakers and decoder up to the digital out on my audigy soundcard. Now first off, the decoder has 3 inputs - analogue stero, digital RCA(coaxial), and digital optical. i've tried doing everything in audioHQ to get
-
Saving Elements 9 Edited photos to IPhoto 11
I am fairly new to using IPhoto. Elements is old hat to me. When I edit a photo in Elements and save it to IPhoto it seems to get lost. I shoot in RAW, cntrl click and say open in external editor (Elements 9) and do my editing. Then I do a "save as"