|
first i want to say that this site is the best in the world, i always find what i want in it
it's great,thanks...
i'm facing a problem in opening jar file(by execute batch file which contains java -jar command) in c#
here is the code:
string filepath = Server.MapPath("test.bat");<br />
<br />
<br />
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");<br />
psi.UseShellExecute = false;<br />
psi.RedirectStandardOutput = true;<br />
psi.RedirectStandardInput = true;<br />
psi.RedirectStandardError = true;<br />
<br />
<br />
Process proc = Process.Start(psi);<br />
StreamReader sr = File.OpenText(filepath);<br />
StreamWriter sw = proc.StandardInput;<br />
StreamReader sre = proc.StandardError;<br />
<br />
while (sr.Peek() != -1)<br />
{<br />
<br />
sw.WriteLine(sr.ReadLine() + Environment.NewLine);<br />
}<br />
<br />
TextBox1.Text = sre.ReadLine();<br />
sr.Close();<br />
proc.Close();<br />
sw.Close();<br />
<br />
the following message appears
Unable to access jarfile *.jar
what do you think the problem is ???
|
|
|
|
|
so jave.exe can't find your jar file . . . did you specify the full path in your batch script? why not just spawn the java process directly?
|
|
|
|
|
I don't know what your problem is, mine is "Unable to access jarfile *.jar" does not
appear in the code you have shown. Maybe it is inside test.bat? Care to show the file's content?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
this is test.bat content :
java -jar *.jar {options }
i don't think the path of the jar file is the problem
cause i put test.bat and *.jar in the same path
how he could see test.bat , and didn't see the jar file
thanks for reply, i'm so happy to register in this great site ..
|
|
|
|
|
Hi,
IIRC Java uses different rules for locating files/classes it needs.
Normally you must set an environment variable "CLASSPATH" and list the places to look,
very similar to what "PATH" does for native Windows applications.
And I typically put "." as the first location, so this is a possible value:
CLASSPATH=.;C:\Program Files\Java\jre1.5.0_05\lib\ext\QTJava.zip
Of course you must set this before you launch java.exe (or the program that will launch it)
since environment variables get copied when a process gets launched.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: C:\Program Files\Java\jre1.5.0_05\lib\ext\QTJava.zip
is this the jar file bath ??
that means i must set classPath every time the program will run .. ??
thanks alot
|
|
|
|
|
I gave you an example, I don't know where your jar file is.
you must list the directories you want Java to search for things it needs.
I recommend you start CLASSPATH with "." so it searches the curdir first.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
hey guys, im writing a custom auto updater, its pretty much done, and i would like to incorporate a file transfer rate (Downloading at 288 KB/s) for when the updates are being downloaded. ive searched google, searched here, couldnt come up with a valid tutorial. im using webclient.downloadfileasync() to get the actual file, any help would be appreciated.
|
|
|
|
|
If you are looking for average transfer rate and/or time remaining, it is fairly simple.
Transfer Rate = amount downloaded / seconds elapased.
Remaining Time = Total Size - Amount Downloaded / Transfer Rate.
If you are using FTP as your mechanism...
Stream ftpStream = response.GetResponseStream();
long cl = response.ContentLength;
int bufferSize = 2048;
int readCount;
byte[] buffer = new byte[bufferSize];
int readCount = ftpStream.Read(buffer, 0, bufferSize);
//download as long as the download is not cancelled.
while (readCount > 0 && _continueUpdating)
{
//For calculationg speed and other good stuff.
_bytesReceived += readCount;
outputStream.Write(buffer, 0, readCount);
readCount = ftpStream.Read(buffer, 0, bufferSize);
}
Good luck, I hope this helps!
|
|
|
|
|
I have a datagridview that on new row entry puts in a different ID than what should be the new record ID. I get a concurrency error because the new ID it's generating, is beyond how many actual records are in the table. Where do I begin to debug, and fix?
Thanks to anyone in advance!
|
|
|
|
|
I'm not able to send APDU to a smart card using winsCard library.
I'm developing in C# 2005, probably the problem is in the definition of
SCardTransmit on winscard or in parameter I'm trying to pass.
if I use the following definition on winscard, SCardTransmit returns 22...
static extern uint SCardTransmit(uint hCard, IntPtr pioSendPci, byte[]
pbSendBuffer, int cbSendLength, ref SCARD_IO_REQUEST pioRecvPci, ref byte[]
pbRecvBuffer, ref int pcbRecvLength);
SCARD_IO_REQUEST ioRecv = new SCARD_IO_REQUEST();
ioRecv.cbPciLength = 0;
byte[] pbRecvBuffer = new byte[2];
int pcbRecvLength = 2;
byte[] pbSendBuffer = { (byte)0x00, (byte)0xA4, (byte)0x04, (byte)0x00, (byte)
0x0A, (byte)0x65, (byte)0x78, (byte)0x6D, (byte)0x5F, (byte)0x77, (byte)0x61,
(byte)0x6C, (byte)0x6C, (byte)0x65, (byte)0x74, (byte)0x00 };
int cbSendLength = pbSendBuffer.Length;
IntPtr pioSendPci = GetPciT0();
uint errors = SCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength,
ref ioRecv, ref pbRecvBuffer, ref pcbRecvLength);
if I use the definition below the error is 2148532243...
uint errors = SCardTransmit(hCard, new SCARD_IO_REQUEST(), pbSendBuffer,
cbSendLength, ioRecv, ref pbRecvBuffer, ref pcbRecvLength);
SCARD_IO_REQUEST ioRecv = new SCARD_IO_REQUEST();
ioRecv.cbPciLength = 0;
byte[] pbRecvBuffer = new byte[2];
int pcbRecvLength = 2;
byte[] pbSendBuffer = { (byte)0x00, (byte)0xA4, (byte)0x04, (byte)0x00, (byte)
0x0A, (byte)0x65, (byte)0x78, (byte)0x6D, (byte)0x5F, (byte)0x77, (byte)0x61,
(byte)0x6C, (byte)0x6C, (byte)0x65, (byte)0x74, (byte)0x00 };
int cbSendLength = pbSendBuffer.Length;
IntPtr pioSendPci = GetPciT0();
uint errors = SCardTransmit(hCard, new SCARD_IO_REQUEST(), pbSendBuffer,
cbSendLength, ioRecv, ref pbRecvBuffer, ref pcbRecvLength);
I've tried changing length of the response, the reference of parameters,
passing null pointer, ecc... but nothing changes.
If you have some advice or better some sample code, it's really appreciated
Thanks in advance
|
|
|
|
|
I am doing a topic about "encrypt text into an image". Who can help me?
Could you tell me how to do it? If you have source, Please send to me. Thanks.
|
|
|
|
|
Please refer to the replies you recieved the last time you posted on Jan 18th 2008 here[^]
Now what bit of this are you having difficulty with? Give us something specific and we'll answer if we can!
The first thing I'd suggest is having a look at Byte arrays ( byte[] ).
Dave
|
|
|
|
|
Thank for your help
I understood the structure of image but
I don't know how to do to encrypt a text file into an image and decrypt again.
with Byte arrays, I understood it, too
Thank you very much for your help
---Thuc---
|
|
|
|
|
there are some documents on steganography in the codeproject articles, might be worth taking a look at some of those.
|
|
|
|
|
Ask Corinna John http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=475133[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
hi all,
How to identify bookmarks and hyperlinks in a pdf file
The need for me is to identify the following
1. To identify broken bookmarks(ie., Book marks not pointing to any location in the pdf)
2. To identify Bookmarks with null text.
3. To identify the Hyperlinks pointing to web page
4. To identify broken hyperlinks (ie., hyperlink pointing to null location)
Thanks in advance
regards
mist
|
|
|
|
|
THanks for listing your requirements, unfortunately, no one cares about them. What are the specific problems you are having in implementing them?
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
I would like to have a property to appear in a visual designer where the user can browse for a file, instead of just entering the path manually.
In a visual designer, your custom component can have properties which are displayed in the properties window of hte designer. For instance, if your property is of type bool , the designer lets you choose between true or false. Likely, if your property is of type Enum , the designer displays the list of the enum values you defined.
Now, I am pretty sure that I can have a property that will make the designer put ellipsis (...) so the user can click it and browse for a file.
If this is possible, what would be the type of my property?
|
|
|
|
|
|
|
Hi, I am creating a 5 star rating control using callbacks.
I am not able to send the value to the parent page and then save it. When I try to capture the click event of the image, I guess multiple events occur and then I loose the actual value. The actual value does not persists.
I have used five image controls and One hiddenField named 'hdn' and have written javascript functions for handling the OnMouseOver, OnMouseOut and Click Event. The functions are s follows:
--------Image Click Event----------
function onImgClick(strVal)
{
var countRec;
var imgName;
var message = strVal + ":" + "Click";
var context = "Click";
CallServer(message, context);
}
------------------------------------
----------OnMouseOver--------------
function callSwapImage(strVal)
{
var countRec;
var imgName;
for (countRec = 1; countRec<=parseInt(strVal); countRec++)
{
imgName = "imgStar" + String(countRec);
document.images[imgName].src = "images/starGold.gif";
}
}
---------OnMouseOut------------
function callSwapRedo()
{
var message = document.getElementById("rc1_hdn").value + ":" + "Redo";
var context = "Redo";
CallServer(message, context);
}
-------------------------------
In the code behind file of the user control I have written the following code in the Page_Load Event
protected void Page_Load(object sender, EventArgs e)
{
sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "ShowSuccess",
"context");
String callbackScript;
callbackScript = "function CallServer(message, context)" +
"{ " + sCallBackFunctionInvocation + ";}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"CallServer", callbackScript, true);
HiddenField hdn = new HiddenField();
}
For the RaiseCallbackEvent I have written
public void RaiseCallbackEvent(string eventArgument)
{
string[] remCount = new string[2];
if (Rated != null)
{
if (eventArgument != "")
{
remCount = eventArgument.Split(':');
if (remCount[1] == "Click")
{
EventArgs args = new EventArgs();
Rated(this, args);
}
}
if (hdn.Value.ToString() == "" && remCount[0] == "0")
{
returnValue = "0";
totChecked = returnValue;
hdn.Value = returnValue;
}
else
{
returnValue = remCount[0];
hdn.Value = returnValue;
totChecked = returnValue;
}
}
RateVal = returnValue;
}
The below function is written to send the result back to the client end
public string GetCallbackResult()
{
return returnValue;
}
-----------------------------------
My problem comes now that I want to send the value for the image clicked to the parent page so that I can save the rating. For this I have declared the following event before the page load
public event System.EventHandler Rated;
and then I have declared the event handler for the same in my parent page
protected void Page_Load(object sender, EventArgs e)
{
rc1.Rated += new EventHandler(rc_fetchData);
//rc.Rated += new CommandEventHandler(rc_fetchData);
}
private void rc_fetchData(object sender, EventArgs e)
{
lblMsg.Text = ((HiddenField)rc1.FindControl("hdn")).Value.ToString();
//((HiddenField)rc.FindControl("hdn")).Value.ToString();
}
-----Have A Nice Day-----
|
|
|
|
|
How can i use two filters in the following code
person pp = obj.Find(delegate(person p) { return p.name == "abc"; });
because there should be one return statement in a single block.
So how will i declare another filter to refine the record
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Sonia - you asked this question below. Don't repost questions, continue threads instead as this is just plain rude.
|
|
|
|
|
You can write several statements and use logical operators to return the value according to your filter requirements.
Logical Operators in C#[^]
|
|
|
|
|