|
I have spent all day trying to figure out this junkstuff and seem to be getting nowhere.
I could have had this damn application done by now using ASP.Net or Silverlight but Nooooooooo.
Anyone have any words of wisdom on how to get simple navigation to work in JSPs?
I just want to be able to click on button on a templated page to move tot he next page and it doe snot seem to work. Of course I can just sett he navigation destination of the button.. Noooooooo I have to set this, then that, draw a link between pages in two areas, then blah blah blah blah blah blah..
ENOUGH!
|
|
|
|
|
what's wrong with Myeclipse7(all in one)???too slow,always stuck when I open a file
Undeniable:More information,more abilities,more energies,more time!
http://www.blogjava.net/tidelgl
|
|
|
|
|
I'm having troubles learning the concept of classes that extend Comparable. Any suggestions out there that could help my understanding? Same thing with abstract classes, I don't get the importance.
thanks in advance.
|
|
|
|
|
jonig19 wrote: I'm having troubles learning the concept of classes that extend Comparable
Which point don't you understand specifically ? If you want your objects to be comparable, you simply implement the Comparable interface and implement the CompareTo function. I really don't understand what you don't understand
jonig19 wrote: Same thing with abstract classes
Again, what is the point you don't understand ? Abstract classes are classes which should not be instanciated, they are only meant to be implemented by child classes. Thus, when you have abstract functions, it means that you have to implement those in your child classes.
|
|
|
|
|
Dear all,
i'm in a middle of a thesis.and i have some problem in getting the frame in video structure, so i can get it as an image.
can any body help me how to do it in java?
Thanx
|
|
|
|
|
any body here know to make Array of record in java script ..
can give me some example ...
thx b4 ..
regards
novhard
|
|
|
|
|
oredy have the answer ..
he he he ^.^
|
|
|
|
|
I've got an applet that needs to retrieve a "preview" of sorts of a file from within the applet. I think the best way to do this is to do what Windows Explorer does, and return an image of the file as a preview (or an icon if it can't preview, like returning the Microsoft Word icon for a .doc or .docx file). I have a feeling that this could be done through Shell32.dll. If so, how can I access that? And if not, is there another way to do this without having to save an image for every extension I might use beforehand?
Thanks.
|
|
|
|
|
hi i have written this code to execute a batch file in windows 2003 server R2
but it does not execute anything. it opens the cmd.exe window and does nothing also
the "Exit Value" and "Return Code" is 0.
can anyone help me about this?
is there any windows registry setting to restrict the execution of batch files programatically?
Thank you!!!!
try
{
Runtime runtime = Runtime.getRuntime();
Process process = null;
try
{
System.out.println( "Running: " + fName + ".bat " );
process = runtime.exec( "cmd /c start " + fName + ".bat" );
int returnCode = process.waitFor();
System.out.println("Exit value " + process.exitValue());
System.out.println("Return code value " + returnCode);
System.out.println("Finished running the SQL Loader script's process. " + " Exit Value = " + ( returnCode == 0? "Success" : "Failure" ) );
}
catch ( Exception e )
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
catch ( Exception e )
{
System.out.println( "Error running the sqlldr script: " + e );
e.printStackTrace();
}
|
|
|
|
|
if your bat script contains spaces or special characters you will need to enclose it in quotes... Dunno if that helps.
|
|
|
|
|
also ensure your path to the bat is readable by javaw -> try putting it in "C:\yourbatscript.bat"
|
|
|
|
|
i am getting the same results. the window title of cmd.exe is the exact path of the bat file but i didn't execute. maybe there is some kind of security setting for java not to invoke the batch files or a setting in windows server...
|
|
|
|
|
No i did this last week. Didn't set anything else.
webtools.java:
private void jButton13ActionActionPerformed(ActionEvent event) {
cmdExec cmd = new cmdExec();
String s = (cmd.run("ping www.google.co.uk"));
jTextPane0.setText(jTextPane0.getText() + s + "\n-----------------------------\n");
}
cmdExec.java:
package webtools;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class cmdExec {
public String run(String cmdLine) {
String line;
String output = "";
try {
Process p = Runtime.getRuntime().exec(cmdLine);
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output += (line + '\n');
}
input.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
return output;
}
}
modified on Wednesday, April 22, 2009 10:13 AM
|
|
|
|
|
I'm starting to learn Java and have been testing Visual Editor in Eclipse. I notice there are several different versions & plug-ins available that are all quite different.
Which Plug-in / Version of Visual Editor do you use? What advantages does it have over other versions / products?
I'm on 0.9 (Has a palette - which I couldnt see on the other versions). It can be a bit buggy though - it doesn't like you making mistakes - and goes nuts if you do.
Which is your favourite and why?
(For items with multiple versions or items with the same name please include update links or version numbers, if possible.)
|
|
|
|
|
I am a C# developer by profession, but recently I have been playing around with Java (have been asked to create a Java game for my company). My question is, in C# you can return a value from a class using something like this:
<br />
public string this[int index]<br />
{<br />
return "yadayadayada";<br />
}<br />
my question is, how do i do the same in Java?
Big thanks, sorry for the noob question but I couldnt get a straight answer from Google
|
|
|
|
|
I am assuming the class extends a List of some kind.
For example:
public class TestClass extends ArrayList<String>
Then use something like this:
public String returnStringAtIndex(int index)
{
return this.get(index);
}
hmmm pie
|
|
|
|
|
is it right that Java doesnt support indexers? guess it doesn't really make a difference
Jonathan Harker
preecesoftware.co.uk
|
|
|
|
|
jharker1987 wrote: is it right that Java doesnt support indexers?
Java doesn't support properties.[^] So you have to use functions instead.
Is that what you mean?
hmmm pie
|
|
|
|
|
any body here have huffman coding decoding and encoding in JSCRIPT ..
if, have, please share with me ...
or give me a link to download it,..
thx very much ...
regards
novhard
|
|
|
|
|
Are you only looking for the a copy of code to cut and paste or are you looking an explaination of how it works and how to write it? I don't know of any examples in jscript but I have done this in C and to be honest the concept is going to be pretty much the same no matter what language you write it in. If you're interested I'd be glad to explain how it generally works in any language (can't say it would be specific to jscript).
Mike
|
|
|
|
|
thx for answering my question ..
i am looking for the copy of code ,
thanks too if u want to give me explanation about the huffman code ...
just give the link, where i can download your huffman code in c,
i will try to translate it to jscript ...
thank you ver ymuch ...
regards
novhard
|
|
|
|
|
I'll have to find the usb drive I have it on since I did it a little while ago. Hopefully I'll find it by tommorrow and post the code so you can see it.
But here's an explaination of how it works (please note if you don't know what a tree, structure, or linked list is I would suggest reading the wikipedia articles to learn that first since huffman uses them):
Suppose you had a long text file where all the letters were either an A,B,C,or D and you wanted to save them in the minumum space possible. Also suppose you knew that 80% were A, 15% were B, 3% were C, 2% were D. You could give each letter a 2 digit binary code but that would not be as efficient as giving the most commons letter(s) a shorter binary code even if this means the less common ones have to be slightly longer code.
For instance huffman would give them these codes:
A = 0
B = 10
C = 110
D = 111
It creates these codes by creating an unbalanced binary tree. To do this you create a list of nodes that are placed in order according to frequency. Then you remove the 2 least common nodes and create a parent node for them that contains the frequency of both nodes and place the parent node back into the list in order. You keep doing this till you have only 1 node and that node is your root node.
Here's what the tree looks like:
Root...................................(ABCD Freq 100%)
Level 1..........(A Freq 80% Code 0)..................(BCD Freq 20%)
Level 2...............................(B Freq 15% Code 10).........(CD Freq 5%)
Level 3.............................................(C Freq %3 Code 110)..(D Freq 2% Code 111)
The codes are determinded by where the node is on the tree. Left is 0 right is 1. To encode you create the tree and write the binary code for each symbol. To decode you start at the root and go left if the number is 0 and right if it is 1. You continue doing this until you reach a leaf node. Once you reach a leaf node you write the letter and start again at the root.
|
|
|
|
|
thx mates ..
i am oready know about the teory ..
but i feel hard to write it down to a code ..
specially in jscript ..
thank you very much for answer my question
regards
novhard
|
|
|
|
|
Basically this is a project I did in college, it reads a file with 0s and 1s (he didn't encript the punctuation) and writes out the message in plain text. He also gives us a file with the frequencies and we also had to print some other misecleous stuff in the console window if I recall.
ps code project system took out the indents in the code and stripped out my includes for some reason, just so you know.
modified on Monday, April 20, 2009 12:44 PM
|
|
|
|
|
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
#define MAXBITS 26
void prq_create(struct prqueue*);
int prq_empty(struct prqueue*);
void prq_insert(struct prqueue*, struct info_node*);
void prq_remove(struct prqueue*, struct info_node*);
void merge_nodes(struct info_node*, struct info_node*, struct info_node*);
void init_node(struct info_node*);
void print_level_order(FILE*, struct info_node*);
void print_code(FILE*, struct info_node*);
int isleft(struct info_node*);
int build_numcode(struct info_node*, int []);
void print_code(FILE*,struct info_node* pleaf_location[]);
void build_pque (FILE*, struct prqueue*, struct info_node* []);
struct info_node* build_tree (struct prqueue*);
void print_inorder(FILE*, struct info_node*);
void decode (FILE* ,struct info_node* , FILE*);
#define TRUE 1
#define FALSE 0
struct info_node
{
char code[MAXBITS] ;
float weight ;
int level ;
struct info_node* father ;
struct info_node* left ;
struct info_node* right ;
struct info_node* next ;
} ;
struct prqueue
{
struct info_node * prqtop ;
};
struct lo_queue
{
struct info_node* front ;
struct info_node* rear ;
};
int main()
{
struct prqueue pque ;
struct info_node* pleaf_location[MAXBITS] ;
struct info_node* tree_root ;
FILE* infile; FILE* outfile; FILE* dec_result; FILE* bitfile;
int count = 0;
infile = fopen("symb_freq.txt", "r");
outfile = fopen("code_tree.txt", "w");
bitfile = fopen("bit_file.txt", "r");
dec_result = fopen("decoded_file.txt", "w");
//builds the priority queue
pque.prqtop = NULL;
build_pque(infile, &pque, pleaf_location);
fclose(infile);
////builds the tree
tree_root = build_tree(&pque);
//does the inorder traversal
print_inorder(outfile, tree_root);
fprintf(outfile, "\n\n");
//prints the level order traversal
print_level_order(outfile, tree_root);
//prints the code for each letter
print_code(outfile, pleaf_location);
//decodes the zeros and ones into a message
decode(bitfile, tree_root, dec_result);
fclose(outfile);
fclose(bitfile);
fclose(dec_result);
return( 0 ) ;
} // end of function main()
void build_pque (FILE* infile, struct prqueue* pque, struct info_node* pleaf_location[])
{
int n = 0; struct info_node* node;
//creates the priority queue and loads pleaf_location array
while(!feof(infile))
{
node = (info_node*) malloc(sizeof(struct info_node));
init_node(node);
fscanf(infile, "%s", &node->code[0]);
fscanf(infile, "%f", &node->weight);
prq_insert(pque, node);
pleaf_location[n] = node;
n++;
}
}
struct info_node* build_tree (struct prqueue* pque)
{
struct info_node* p1; struct info_node* p2;
struct info_node* rnode; struct info_node* tree_root;
//builds the tree
while(pque->prqtop->next != NULL)
{
p1 = pque->prqtop;
p2 = p1->next;
pque->prqtop = p2->next; //moves top to the next spot
rnode = (info_node*) malloc(sizeof(struct info_node));
init_node(rnode);
merge_nodes(p1, p2, rnode);
prq_insert(pque, rnode);
}
tree_root = pque->prqtop;
pque->prqtop = NULL;
return tree_root;
}
void print_code(FILE* outfile, struct info_node* node)
{
int n = 0;
while(node->code[n] != '\0')
{
fprintf(outfile, "%c",node->code[n]);
n++;
}
fprintf(outfile, " ");
}
//makes a node and inititializes it
void init_node (struct info_node* node)
{
node->father = NULL;
node->left = NULL;
node->right = NULL;
}
//test if it is empty
int prq_empty(struct prqueue* prq)
{
if (prq->prqtop == NULL)
return TRUE;
else
return FALSE;
}
//inserts node into priority queue
void prq_insert(struct prqueue* prq, struct info_node* node)
{
struct info_node* curnode; struct info_node* lastnode = NULL;
curnode = prq->prqtop;
if ((curnode == NULL) || (node->weight <= curnode->weight)) //inserts at the start of the queue
{
node->next = curnode;
prq->prqtop = node;
}
else //moves through the list and inserts at the right spot
{
//lastnode = curnode;
//curnode = lastnode->next;
while ((curnode != NULL) && (node->weight > curnode->weight))
{
lastnode = curnode;
curnode = lastnode->next;
}
lastnode->next = node;
node->next = curnode;
}
return;
}
//removes one node and passes it back by reference
void prq_remove(struct prqueue* prq, struct info_node* node)
{
node = prq->prqtop;
prq->prqtop = node->next;
node->next = NULL;
}
//this creates a new node above the 2 existing nodes and calculated values for the new node
void merge_nodes(struct info_node* p1, struct info_node* p2, struct info_node* rnode)
{
//links nodes
rnode->left = p1;
rnode->right = p2;
p1->father = rnode;
p2->father = rnode;
//calculates value for the father
rnode->weight = p1->weight + p2->weight;
strcpy(rnode->code , p1->code);
strcat(rnode->code, p2->code);
//clears old links
p1->next = NULL;
p2->next = NULL;
}
//builds the code in left to right order. //this will be reversed when it is read
int build_numcode(struct info_node* node, int numcode [])
{
int count = 0;
while (node->father != NULL)
{
if (isleft(node))
{
numcode[count] = 0;
count += 1;
}
else
{
numcode[count] = 1;
count += 1;
}
node = node->father;
}
return count;
}
//test if the node is on the left side of the father node
int isleft(struct info_node* node)
{
if (node == node->father->left)
return TRUE;
else
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
// PRINTS THE CODE FOR EACH LETTER
void print_code(FILE* outfile, struct info_node* pleaf_location[])
{
int n; int a; int count; int numcode[10];
//prints the code for each letter
fprintf(outfile, "\n\n");
for (n = 0; n < MAXBITS; n++)
{
count = build_numcode(pleaf_location[n], numcode);
fprintf(outfile, "Symbol: %c Huffman Code: ", pleaf_location[n]->code[0]);
for (a = (count - 1); a >= 0; a--) //prints code in reverse order
fprintf(outfile, "%d", numcode[a]);
fprintf(outfile, "\n");
}
}
////////////////////////////////////////////////////////////////////////////////
// IN ORDER TRAVERAL CODE
void print_inorder(FILE* outfile, struct info_node* node)
{
if (node != NULL)
{
print_inorder(outfile, node->left);
fprintf(outfile, "FREQUENCY: %f SYMBOL: ", node->weight);
print_code(outfile, node); //prints out all the letters
fprintf(outfile, "\n");
print_inorder(outfile, node->right);
}
}
////////////////////////////////////////////////////////////////////////////////////////
//LEVEL ORDER TRAVERSAL CODE
//prints the current layer and gets nodes of the next layer
void print_level_order(FILE* outfile, struct info_node* tree_root)
{
struct info_node* left; struct info_node* right; int level = 0;
struct lo_queue* queue;
queue = (lo_queue*) malloc(sizeof(struct lo_queue));
//prints out the levels
tree_root->level = 0;
queue->rear = tree_root;
queue->front = tree_root;
fprintf(outfile, "level 0: ");
//print_levels(outfile, &real_queue);
while(queue->rear != NULL)
{
if (queue->rear->level != level) //if level changed
{
fprintf(outfile, "\n");
fprintf(outfile, "level %d: ", queue->rear->level);
}
print_code(outfile, queue->rear);
level = queue->rear->level;
//puts atoms in the queue
left = queue->rear->left;
if (left != NULL)
{
left->level = level + 1;
queue->front->next = left;
queue->front = left;
}
right = queue->rear->right;
if (right != NULL)
{
right->level = level + 1;
queue->front->next = right;
queue->front = right;
}
queue->rear = queue->rear->next;
}
}
////////////////////////////////////////////////////////////////////////////////////////
//Decoding
void decode (FILE* infile,struct info_node* tree_root, FILE* outfile)
{
char num; int n = 0; struct info_node* node;
node = tree_root;
while(!(feof(infile)))
{
fscanf(infile, "%c", &num);
if (num == '0')
{
node = node->left;
if (node->left == NULL) //is a leaf node
{
fprintf(outfile, "%c" , node->code[0]);
node = tree_root;
}
}
else if (num == '1')
{
node = node->right;
if (node->right == NULL) //is a leaf node
{
fprintf(outfile, "%c" , node->code[0]);
node = tree_root;
}
}
else
{
fprintf(outfile, "%c", num);
}
n++;
}
}
|
|
|
|
|