| casting from int to byte problem |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- coordinating eventsHi there,
I'm having difficulty trying to coordinate the sequence of events for
populating a JTree with data received from a server app. I'm so-o-o-o close
and yet no banana! It's proving to be very tricky processing. I could use
some help in trying to make this work properly. Perhaps you may understand
better as to why my efforts are being thwarted by the either the JTree
object or its DefaultTreeModel?
Here's the setup:
1) I have a server app that, when requested from the client app, will
provide a child count on any given directory node on the server. Also, it
will serve up the names of each child node for any given node upon request.
2) The client app contains a JTree object that I'm trying to initially
populate with the root node. Subsequently, the plan is to dynamically
populate any directory node in the JTree whenever the treeWillExpand( ... )
event is triggered as the user tries to expand on a node.
3) Throughout my code I have a number of System.out.println( ... )
statements so that I can see what sequence of events are taking place as the
client app makes requests to the server and receives replies back from the
server. Also, some println(...) statements in some key methods which you'll
see.
4) The sequence of events is supposed to go like so:
i) root node is created
ii) as the root node is passed as a parameter when creating the JTree
object
the getChildCount( ) method of the root node [type DefaultTreeNode
extends DefaultMutableTreeNode ]
is called.
public int getChildCount()
{
if (!hasChildren)
{
defineChildNodes();
}
return(super.getChildCount());
}
iii) Since the root node initially has no children, getChildCount( )
then calls the method
defineChildNodes( ).
protected void defineChildNodes()
{
hasChildren = true;
ref.requestChildCountFromServer(this);
}
As you can see, defineChildNodes( ) simply sets the flag
hasChildren to true then
calls a method requestChildCountFromServer(this) which exists in a
class called Response
referred here by the variable "ref". Also in the Response class
there exists the method
populateTree( ) which initially created the root node and JTree
objects:
protected void populateTree(String NodeName)
{
//System.out.println("Entering populatTree() method");
//This could take a while, so change the cursor icon
//ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try
{
String separator = "";
if(ref.serverOS.equals("Windows"))
separator = "\\";
else
separator = "/";
rootNode = new DefaultTreeNode(NodeName, true, separator);
expandingNode = rootNode;
String rootPath = getLeadingPath(ref.rootPath);
rootNode.setLeadingPath(rootPath);
rootNode.setResponseReference(this);
jTree1 = new JTree(rootNode);
jTree1.setRootVisible(true);
jTree1.setShowsRootHandles(true);
jTree1.collapseRow(0);
MouseListener popupListener = new PopupListener(ref);
jTree1.addMouseListener(popupListener);
//Listen to our own expand/collapse events to keep the labels in
sync
jTree1.addTreeWillExpandListener(this);
}
catch(Exception e){System.out.println("Exception in populateTree()
method"); e.printStackTrace();return;}
....
....
}
iv) The requestChildCountFromServer( ) method then makes a request to
the server app for
the child count for the root node.
v) I have a separate thread running that listens for all responses
from the server
called ResponseListener. In its run( ) method I have the
following code:
else if(connected == ref.ref.SENDING_CHILDCOUNT)
{
System.out.println("Received message: ReceivingChildCount");
ref.expandingNode.numChildren = input.readInt();
//expandingNode.setReceivedChildCount(true);
ref.ref.imageLabel.setIcon(ref.ref.blank);
ref.ref.textLabel.setText("");
}
When the root node was originally created I set a reference to it
using a variable
named expandingNode. Here you can see that the root node's
instance variable
named numChildren is set to a value read in by the DataInputStream
object
named input.
vi) The requestChildCountFromServer( ) method in turn calls another
method in the
Response class named RequestChildrenFromServer(String path).
RequestChildrenFromServer(String path) method requests from the
server the names
of all the child nodes for the root node.
vii) ResponseListener then receives a response from the server:
else if(connected == ref.ref.SENDING_TREE_DATA)
{
System.out.println("Received message: SendingTreeData");
ref.expandingNode.TreeDataIncoming = true;
ref.expandingNode.ReceiveChildrenFromServer(input);
ref.ref.imageLabel.setIcon(ref.ref.blank);
ref.ref.textLabel.setText("");
}
Here you can see that the root nodes method named
ReceiveChildrenFromServer(input) is then called
while passing it a reference to the DataInputStream so that the
method can
read in the names of the child nodes as they come in over the
wire.
viii) The root node's method ReceiveChildrenFromServer(input) then
begins receiving the
names of each child node, creates a new DefaultTreeNode object
for each child node
and adds it to the root node, seen below:
protected void ReceiveChildrenFromServer(DataInputStream input)
{
System.out.println("Entering ReceiveChildrenFromServer()");
DefaultTreeNode child = null;
String name = "";
try
{
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
//System.out.println("numChildren = " + numChildren);
int nodeType = 0;//default
//iterate through each of the children as they come in
//from the server.
for(int i = 0; i < numChildren; i++)
{
name = input.readUTF(); //get the name
System.out.println("child node: " + name);
child = new DefaultTreeNode(name); //create a new
child node
//determine if this node is a directory
//or a file. Empty directories are denoted
//as having (nodeType == -1)
nodeType = input.readInt();
//System.out.println("node type: " + nodeType);
if(nodeType == 0)
{
//Since a file is a leaf node
//we won't be needing to continue
//reading in nodes for it.
child.setResponseReference(ref);
child.setAllowsChildren(false);
child.setHasChildren(false);
child.setLeadingPath(getWholeServerPath());
if(ref.ref.serverOS.equals("Windows"))
child.setSeparator("\\");
else
child.setSeparator("/");
}
else if(nodeType == -1)
{
child.setResponseReference(ref);
child.setAllowsChildren(true); //It's an empty
directory
child.setHasChildren(false);
child.setLeadingPath(getWholeServerPath());
if(ref.ref.serverOS.equals("Windows"))
child.setSeparator("\\");
else
child.setSeparator("/");
}
else
{
child.setResponseReference(ref);
child.setAllowsChildren(true); //It's a directory
with child nodes
child.setHasChildren(true);
child.setLeadingPath(getWholeServerPath());
if(ref.ref.serverOS.equals("Windows"))
child.setSeparator("\\");
else
child.setSeparator("/");
}
this.insert(child,i);
}//end for loop
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}//end try
catch(IOException ioe){ioe.printStackTrace();}
catch(NullPointerException npe){npe.printStackTrace();}
}//end method
IT IS HERE THAT I RUN INTO PROBLEMS!!!!
All the code you see compiles fine. What I found annoying is that, at
run-time, the sequence of events were as I depict them here until I start
reading in the names of the childnodes with the
ReceiveChildrenFromServer(...) method. While it is going through its for
loop, mysteriously the method getChildCount( ) is called again, which in
turn calls defineChildNodes( ), which in turn calls
requestChildCountFromServer(...), which interrupts the processing of the for
loop in ReceiveChildrenFromServer(...) . Here is the read out from the
console to prove it:
***************************************
Entering requestChildCountFromServer
waiting for response...
checking...
Received message: ReceivingChildCount
checking...
got ChildCount: 26 <<<Root node has 26 child nodes
Entering RequestChildrenFromServer()
path is: C:\JavaProjects
Finished calling server for children
Received message: SendingTreeData
Entering ReceiveChildrenFromServer()
checking for tree data ...
child node: AssignmentServer <<<<ReceiveChildrenFromServer(...)
method begins reading in names
child node: AssignmentSubmitter
child node: Borland
child node: ClientServerJTreeProject
child node: DBJavaBean
child node: DirAdmin.bak
Entering requestChildCountFromServer <<<This method is called by
defineChildNodes( ) which was
called by getChildCount( )
waiting for response...
checking...
checking...
Node Expanding.
checking...
checking...
got ChildCount: 0 <<< Don't know
why this is reading zero. It should be 26
child node: DirectoryAdministratorProject <<<For loop from
ReceiveChildrenFromServer(...) method
resumes reading in names
child node: EZSmtp
child node: Icon Editor
child node: images
child node: IniFileProject
child node: J2exe
child node: JCalculator
child node: JGridProject
child node: JSlideShow
child node: MSSTextEditorProject
child node: MySQL_JDBC
child node: PersonalNetSearchProject
child node: Print_Preview
child node: PropertiesFileAccessExample
child node: Sample_EBusiness
child node: SharewareProject
child node: SystemTreeProject
child node: TestProgram
child node: Thread_Pooling
child node: ZeroG
Received message: ReceivingChildCount
*****************************************
Ultimately, I wind up with a root node being displayed in the JTree that
only has maybe five or six child nodes displayed when there should be 26
child nodes.
For further clarity here are the methods requestChildCountFromServer(...)
and RequestChildrenFromServer(...):
public void requestChildCountFromServer(DefaultTreeNode node)
{
System.out.println("Entering requestChildCountFromServer");
String name = "";
try
{
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
output.writeInt(ref.PATH);
output.flush();
output.writeUTF(node.getWholeServerPath());
output.flush();
output.writeInt(ref.REQUEST_CHILD_COUNT);
output.flush();
System.out.println("waiting for response...");
timer1 = new ChildCountTimer(node);
timer1.start();
timer1.join();
System.out.println("got ChildCount: " + node.numChildren);
if(node.numChildren > 0)
{
//NodeExpanding = false; //reset
RequestChildrenFromServer(node.getWholeServerPath());
//Set up TreeDataTimer so that we know we have a
//response from the server.
timer2 = new TreeDataTimer(node);
timer2.start();
timer2.join();
}
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
catch(InterruptedException ie){}
catch(IOException ioe){ioe.printStackTrace();}
catch(NullPointerException npe){npe.printStackTrace();}
}
protected void RequestChildrenFromServer(String path)
{
System.out.println("Entering RequestChildrenFromServer()");
//Request Children from server
try
{
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
output.writeInt(ref.PATH);
output.flush();
System.out.println("path is: " + path);
output.writeUTF(path);
output.flush();
//Sending REQUEST_CHILDREN should cause a response
//from the server: SENDING_TREE_DATA
output.writeInt(ref.REQUEST_CHILDREN);
output.flush();
//ref.ref.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
catch(IOException ioe){ioe.printStackTrace();}
System.out.println("Finished calling server for children");
}
I realize this post is rather lengthy, however, I didn't know how else to
explain my dilemma with this project. If you need more information, just
ask.
Please advise,
Alan
- 3
- JSTL & Source Code
JavaScript and CSS programmers have for years, been looking for the
"holy grail", i.e., the ability to hide source code.
Take at look at www.dice.com, do a job search then view source.....
nothing there except JSTL noatation per below:
-------------------------- start -------------------------------------
<!--
* $RCSfile: abbreviated.jsp,v $
* $Author: duket $
* $Date: 2005/06/15 13:36:17 $
-->
<!-- START JSTL_INITIALIZATION -->
<!-- FINISH JSTL_INITIALIZATION -->
------------------------ end -----------------------------------------
Was not aware that a fringe benefit of JSTL was the ability to hide
html source code. How secure is this? Can someone hack it to get the
html source?
I'm one of those Java/JavaScript/CSS programmers that has created
graphics with CSS on Web pages and would like to keep the code
private. I have found a crude way but I like the above better.
Thanks
- 3
- redirect problemHi everyone,
I have a problem, I am connectin to a lotus notes database to download
a file (using URLConnection)
...gbp.nsf/agWebLAL?OpenAgent&UNID=A9D19EDE65447DF5C1256F2000465E87
The thing is lotus notes doesn't give the filename, it redirects me to
something first, then downloads the filename..
Does anyone know of a way on how I can get the final url (the place
where I am being redirected), filename and mimetype
Thanks!
- 3
- To getenv or not getenvI'm using 1.4.2 for some commecial development. I was just about to set
a property and pass it on the command line when I noticed that System.getenv is
not deprecated in 1.5.0. So is it bad form to use a deprecated 'getenv'
in 1.4.2 given its new lease of life in 1.5.0??
Being 'allowed' to use getenv would make certain parts of the program
more expressive.
Cheers,
Lordy
- 3
- [ANNOUNCE] DataDirect Technologies Releases DataDirect XQuery to Simplify XML and Relational Data Integration[ANNOUNCE] BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies
(http://www.datadirect.com), the software industry leader in
standards-based components for connecting applications to data and an
operating unit of Progress Software Corporation, today announced the
release of DataDirect XQuery(TM), the first embeddable component for
XQuery that is modeled after the XQuery API for Java(TM) (XQJ).
Developers can download a free trial of DataDirect XQuery today at:
http://www.datadirect.com/downloads/registration/xquery/index.ssp
"Internet developers typically spend much of their time creating and
restructuring XML, using data from many sources, generally including
relational data. This task is much too tedious in most environments.
Using DataDirect XQuery, which is based on the W3C's XML Query
(XQuery), simplifies the programming task significantly, solving the
same problems with much less code," said Jonathan Robie, Program
Manager for DataDirect XQuery and an editor of the W3C XQuery
specification. "Using DataDirect XQuery means that your applications
can run on any Java platform, accessing data from the major relational
databases, using any Web server or application server, or using no
server at all. And DataDirect XQuery performs quite well, even when
your query creates large XML results."
DataDirect XQuery supports all major relational databases, including
Oracle, Microsoft SQL Server 2000, IBM DB2, and Sybase, on any Java
platform, allowing developers to query XML, relational databases, or a
combination of the two. Query results can be used for XML-based data
exchange, XML-driven Web sites, and other applications that require or
leverage the power of XML. DataDirect XQuery provides IT professionals
with a highly productive, powerful, simple, and standards-based
approach to XML and relational data integration.
Simplifying XML and Relational Data Integration
DataDirect XQuery simplifies XML and relational data integration by
providing developers with an XQuery implementation that offers greater
productivity, performance and interoperability for building
standards-based data integration applications, and here's how:
?Productivity: Web services, Web sites, data integration, and
publishing are just a few examples of the many types of applications
that need data from many sources, including relational and XML. For the
first time, DataDirect XQuery enables developers to easily process both
XML and relational data using industry-standard XQuery. DataDirect
XQuery simplifies application development by reducing the amount of
code developers write and maintain to use XML and relational data
together. The result: reduced application complexity, shorter
development cycles and more powerful applications - all based on the
current W3C XQuery standard yet to be finalized.
?Performance: DataDirect XQuery optimizes and mediates query
performance when accessing relational data. DataDirect XQuery is
designed to move the minimum amount of data out of the database - for
example, XQuery code is converted to SQL statements which are executed
on the database server - thus providing the best performance possible.
?Interoperability: It's easy to embed DataDirect XQuery in
applications: it does not require any other product or application
server, it has no server of its own, it is not tied to a specific
vendor database or database version, and it is based on the current
version W3C XQuery and XQuery API for Java (XQJ) standards yet to be
finalized. Application developers can write one easy-to-maintain
application, regardless of the databases and versions they are using -
Oracle, DB2, Microsoft SQL Server, or Sybase. This approach results in
more extensible and interoperable applications which are insulated from
the frequent database updates and changes in the database vendor tools.
"In the past, our web-based XML Human Resources applications generated
and sent XML data using data stored in an Oracle database," said Mark
Zimmerman, VP of IT, at Gevity, a leading provider of employee
management solutions. "We found DataDirect XQuery to be fast, scalable,
and reliable. And because DataDirect XQuery allows us to leave the data
access code in the middle tier, and not tied to a specific database,
our application is insulated from any changes in the back end,
improving application interoperability. Overall, we're very pleased
with DataDirect XQuery."
"Most XQuery implementations either work only with XML files in memory,
or are bound to a particular database or application server - these are
serious restrictions if your organization or partners have different
databases, require scalability, or need to integrate with legacy data,"
said Jerry King, Vice President of the XML Products Group at DataDirect
Technologies. "DataDirect XQuery is the first and only product that
truly makes your XQuery just as portable as your XML - you can use it
on any Java platform, with any major relational database, and it
integrates seamlessly with your Java applications using an industry
standard query language and processing API. DataDirect XQuery is a
quantum leap forward in data integration technology, providing
developers with more power, performance and interoperability than ever
before, and developers can download and try it out today."
Availability
DataDirect XQuery is available today. For more information, please
contact Nancy Vodicka at 919-461-4326, or visit our Web site at
www.datadirect.com/xquery. Developers can also download the DataDirect
XQuery for a free 15-day trial at:
http://www.datadirect.com/downloads/registration/xquery/index.ssp
About DataDirect Technologies
DataDirect Technologies is focused on standards-based data
connectivity, enabling software developers to quickly develop and
deploy business applications across all major databases and platforms.
DataDirect Technologies offers the most comprehensive, proven line of
data connectivity components available anywhere. Developers worldwide
at more than 250 leading independent software vendors and thousands of
corporate IT departments rely on DataDirect?products to connect their
applications to an unparalleled range of data sources using
standards-based interfaces such as ODBC, JDBC and ADO.NET. Developers
also depend on DataDirect to radically simplify complex data
integration projects using XML products based on the emerging XQuery
and XQJ standards. DataDirect Technologies is an operating unit of
Progress Software Corporation, a US$300+ million global software
industry leader. Headquartered in Bedford, Mass., DataDirect
Technologies can be reached on the Web at www.datadirect.com or by
phone at +1-800-876-3101.
DataDirect and DataDirect XQuery are trademarks or registered
trademarks of DataDirect Technologies Corp. in the U.S. and other
countries. Java and all Java based marks are trademarks or registered
trademarks of Sun Microsystems, Inc. in the U.S. and in other
countries. Any other trademarks contained herein are the property of
their respective owner
Contact:
DataDirect Technologies
Nancy Vodicka, 919-461-4326
email***@***.com
- 3
- Referencing enclosing class from inner classHi everyone,
I'm trying to understand inner classes, but came across the following
problem. If I define two types (one is an inner class), and each type
has a method with the same name, is there a way that I can call the
enclosing instance's method from within an instance of the inner class?
I'm guessing that (as per the example pasted below) the getValue()
methods aren't overloaded or overridden because the two classes don't
participate in super-class/sub-class OO relationship. I'd be grateful
for any insight.
Thanks,
Jonathan
public class EnclosingClass {
private int _value = 100;
private class InnerClass
{
public int getValue()
{
return _value * 2;
}
public void println()
{
System.out.println(getValue()); //<-- inner
System.out.println(getText()); //<-- enclosing
}
}
public int getValue()
{
return _value;
}
public String getText()
{
return "hello!";
}
public static void main(String[] args)
{
// create an instance of both classes and call the println method of
the inner class
new EnclosingClass().new InnerClass().println();
}
}
- 4
- JPogressBar does not update UIHi,
i would like to show a JProgessBar during a longer process. I can show
it, but I cannot get the JProgressBar to update the UI, so it just
appears and at the end it disappears again, but it's not changed in the
meantime.
Example code, JProgressBar in JDialog, Java 1.4.2:
public class DialogProgressBar extends JDialog {
private JProgressBar jpb;
public DialogProgressBar(String title, java.awt.Frame owner, boolean
modal) {
super(owner, title, modal);
jpb = new JProgressBar();
jpb.setStringPainted(true);
this.getContentPane().add(jpb, java.awt.BorderLayout.CENTER);
setSize(300,50);
}
public JProgressBar getProgressBar() {
return jpb;
}
}
and that's how I use the Dialog/JProgressBar.
...
DialogProgressBar pb = new DialogProgressBar("Titel", dialog, false);
...
public void actionPerformed(ActionEvent aE) {
...
else if(cmd.equals("mniSynchronize")) {
int selectedRows = 3;
pb.getProgressBar().setMinimum(0);
pb.getProgressBar().setValue(0);
pb.getProgressBar().setMaximum(selectedRows);
pb.setVisible(true);
for(int i=0;i<selectedRows;i++) {
switch(i) {
case 1: pb.getProgressBar().setString("file001");
storeFiletype001();
break;
case 2: pb.getProgressBar().setString("file002");
storeFiletype002();
break;
case 3: pb.getProgressBar().setString("file003");
storeFiletype003();
break;
}
pb.getProgressBar().setValue(i+1);
}
pb.setVisible(false);
}
}
Thanks,
Aloys
- 4
- slow axis performance vs JAX-RPC?hi..
i've been mainly using axis framework for webservices becouse it's
simpler, how ever i was told it's the slowers implementions of them
all, are there any non-commercial frameworks ? simple to use? (and
production ready not beta).
- 5
- Finding memory leak in big appI have an application that uses a lot of memory (up to a gig) and I'm
trying to track a memory leak. The problem is that all of the tools I've
found can't handle such large heap sizes. They generally just run out of
memory themselves.
The bulk of the memory is taken up by double[] and char[], but I need to
know who owns these arrays so I can see why there are so many of them. Is
there any tool that will let me track object ownership, or just give me a
useful heap dump that I can parse myself?
I'm running this on red hat advanced server 4 proc/8gig ram.
I can work with any jdk that's version 1.4.0_01 or higher.
Thanks
- 6
- difference between endorsed and lib folders?hi..
can somone please explain to me what is the difference between the
endorsed and lib folders in common folder in tomcat? i tried reading
the documentation but i couldn't figure it out.
- 8
- how to add double key listenerhi,
i want to catch the key event when SHIFT+TAB are pressed simultaneously
to shift focus to the previous focusable component. the key event is
caught on a JComboBox. if somebody knows the code to do so plz post it.
thanx in advance.
- 10
- Certification is a must in MNCs,the comming Future.Certification is a mark of excellence that you carry with you
everywhere you go.
Integer is a authorised testing center for .Net, Java, J2EE, Testing
etc..... for the clients like Microsoft, Sun, IBM, Exin, Lotus and
many more...
We offer certifications on:
Microsoft
Sun Microsystem
Adobe Systems
Cognos
Comptia
CWNP
EMC2
Enterasys Networks
Exin
Help Desk Institute
Huawei
IBM
Juniper Networks
and many more...
For more details Visit: http://www.integerblr.com
For Registration: http://www.integerblr.com/registration/thomsonprometric.asp
Regards
Ramesh
- 11
- javadoc -linkoffline helpHowdy All!
I am trying to issue a javadoc command with the following linkoffline
option:
-linkoffline http://java.sun.com/j2se/1.4.1/docs/api
C:/java/j2sdk1.4.1_01/docs/api
Both the file path and the url are valid, but I find the generated
links are of the form:
file:///E:/phd/semiInterface/doc/http://java.sun.com/j2se/1.4.1/docs/api/java/lang/reflect/Method.html
Can anyone advise how I can make this work?
Thanks for any help!
Rob
:)
- 12
- Zip file directory creation problemWhile extracting zip files I've come accross a strange error. I use the
code below to check if the directory exists and create it if necessary. The
problem is that it works for most zip files but I have a few zip files that
do not properly extract using this code.
What seems to be happening is the variable e is referencing a ZipEntry that
is a directory but it is not being recognized as a directory in the code.
So I get the following debug info printed:
Extracting AuthorizedDBProject.zip to: D:\zips\AuthorizedDBProject
D:\zips\AuthorizedDBProject\AuthorizedDBProject\AuthorizedDBProject.jpx (The
system cannot find the path specified)
The ZipEntry is: AuthorizedDBProject/AuthorizedDBProject.jpx but
AuthorizedDBProject is not being created before extracting
AuthorizedDBProject.jpx.
Any pointers, suggestions will be appreciated.
Code:
________________
//location - a base directory to extract all the files
try {
in = new BufferedInputStream ( new FileInputStream ( _file ) );
zin = new ZipInputStream ( in );
ZipEntry e;
while ( ( e = zin.getNextEntry () ) != null ) {
File entryPath = new File ( location.toString () + File.separator +
e.getName ());
if ( e.isDirectory () ) {
if ( !entryPath.exists()) {
if(entryPath.mkdir()){
System.out.println (entryPath + " does not exist,
creating..." );
}else{
System.out.println (entryPath + " does not exist and there was
a problem creating it!!!" );
}
}
continue;
}
System.out.println(e.getName() + " is NOT a directory");
System.out.println ( "Extracting: " + e.getName() + " to " +
entryPath );
out = new FileOutputStream ( entryPath );
byte[] b = new byte[ 512 ];
int len = 0;
while ( ( len = zin.read ( b ) ) != -1 ) {
out.write ( b , 0 , len );
}
out.close ();
}
extracted = true;
} catch ( FileNotFoundException ex ) {
System.out.println ( ex.getMessage () );
} catch ( IOException io ) {
System.out.println ( io.getMessage () );
} finally {
if ( out != null ) {
try {
out.close ();
} catch ( IOException ex1 ) {
System.out.println ( ex1.getMessage () );
}
}
...
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
- 14
- Error Installing Jboss ServerHi,
I am trying to install Jboss application server on linux. When I ran sh
run.sh from Jboss Bin Directory, It gave me the following
messages/Errors.
JBoss Bootstrap Environment
JBOSS_HOME: /home/cabig/jboss-4.0.2
JAVA: /usr/java/j2sdk1.4.2_11/bin/java
JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh
CLASSPATH:
/home/cabig/jboss-4.0.2/bin/run.jar:/usr/java/j2sdk1.4.2_11/lib/tools.jar
=========================================================================
Failed to boot JBoss:
java.lang.ClassNotFoundException: org.jboss.system.server.ServerImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at
org.jboss.system.server.ServerLoader.createServer(ServerLoader.java:271)
at
org.jboss.system.server.ServerLoader.load(ServerLoader.java:253)
at org.jboss.Main.boot(Main.java:187)
at org.jboss.Main$1.run(Main.java:463)
at java.lang.Thread.run(Thread.java:534)
Kindly let me know what the error is ? How to solve this ?
Appreciate your Help,
Thanks
shan
|
| Author |
Message |
buu

|
Posted: 2007-9-9 6:04:00 |
Top |
java-programmer, casting from int to byte problem
it looks like I have a strange problem.
I have a small class with several byte 'properties'
and I put a values into them from int values casting them to byte..
but for some values (like 143), casting result (with (byte)) is -113???
it's the same with 147 casted to -109...
and it should be a byte value (means, there should be no negative values)..
value is lowered for 256
why?
did I missed something?
|
| |
|
| |
 |
Patricia Shanahan

|
Posted: 2007-9-9 6:13:00 |
Top |
java-programmer >> casting from int to byte problem
buu wrote:
> it looks like I have a strange problem.
> I have a small class with several byte 'properties'
>
> and I put a values into them from int values casting them to byte..
> but for some values (like 143), casting result (with (byte)) is -113???
> it's the same with 147 casted to -109...
> and it should be a byte value (means, there should be no negative values)..
>
> value is lowered for 256
> why?
>
> did I missed something?
>
>
You missed the fact that Java byte is a signed data type, value range
-128 through +127.
Is there a particular reason for using byte, rather than a wider data
type, such as int, whose value range includes 143 and 147?
Patricia
|
| |
|
| |
 |
Arne Vajh鴍

|
Posted: 2007-9-9 6:14:00 |
Top |
java-programmer >> casting from int to byte problem
buu wrote:
> it looks like I have a strange problem.
> I have a small class with several byte 'properties'
>
> and I put a values into them from int values casting them to byte..
> but for some values (like 143), casting result (with (byte)) is -113???
> it's the same with 147 casted to -109...
> and it should be a byte value (means, there should be no negative values)..
>
> value is lowered for 256
> why?
>
> did I missed something?
The valid range for a byte in Java is -128 to 127.
Arne
|
| |
|
| |
 |
Lew

|
Posted: 2007-9-9 6:31:00 |
Top |
java-programmer >> casting from int to byte problem
"buu" wrote:
>> it looks like I have a strange problem.
>> I have a small class with several byte 'properties'
>>
>> and I put a values into them from int values casting them to byte..
>> but for some values (like 143), casting result (with (byte)) is -113???
Hunter Gratzner wrote:
> Bytes in Java are signed.
<http://java.sun.com/docs/books/tutorial/index.html>
in particular
<http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html>
--
Lew
|
| |
|
| |
 |
Arne Vajh鴍

|
Posted: 2007-9-9 10:31:00 |
Top |
java-programmer >> casting from int to byte problem
Mike Schilling wrote:
> "Hunter Gratzner" <email***@***.com> wrote in message
>> Get a Java book. Bytes in Java are signed.
>
> Which was, by the way, a bad idea.. I've never seen a program that wants to
> do signed arithmetic on bytes. I've seen lots that assemble bytes into
> chars and ints by shifting and or-ing, which would be much simpler and more
> reliable if the damned things didn't sign-extend.
C# got that one right: int, uint, byte and sbyte.
Arne
|
| |
|
| |
 |
curt

|
Posted: 2007-9-9 12:01:00 |
Top |
java-programmer >> casting from int to byte problem
"Mike Schilling" <email***@***.com> wrote:
> "Hunter Gratzner" <email***@***.com> wrote in message
> news:email***@***.com...
> > On Sep 9, 12:04 am, "buu" <email***@***.com> wrote:
> >> it looks like I have a strange problem.
> >> I have a small class with several byte 'properties'
> >>
> >> and I put a values into them from int values casting them to byte..
> >> but for some values (like 143), casting result (with (byte)) is
> >> -113???
> >
> > Get a Java book. Bytes in Java are signed.
>
> Which was, by the way, a bad idea.. I've never seen a program that wants
> to do signed arithmetic on bytes. I've seen lots that assemble bytes
> into chars and ints by shifting and or-ing, which would be much simpler
> and more reliable if the damned things didn't sign-extend.
Yeah, signed bytes are stupid.
I don't know the actual history of what happened in Java, but I assume Java
just copied the C and C++ convention of chars being signed. The reason
bytes are signed in C is because of the PDP-11. When you did a byte move
into a register (registers were all 16 bits) it was sign extended by
default. There was no way to do a byte move to a register without the sign
extension happening and there were no ways to reference the high and low
bytes of the register as if they were separate byte registers. All you
could do was a byte-move from a memory location to one of the general 16
bit registers and you got the sign extension whether you wanted it or not.
If you wanted to undo the sign extension, you just had to zero out the high
order bits with a bit clear instruction.
Given the limited complexity of the computers in those days (very limited
sized instruction sets) you can see why the designers of the PDP-11 might
have chosen it to work that way. They couldn't justify having both signed,
and unsigned, byte move instructions, so they had to pick one behavior for
the byte move. It was a 16 bit machine, with byte addressable memory. All
the registers were 16 bits (including the program counter and stack
pointer). If you did a byte move to the register, and performed math on it
(16 bit), and did a byte move back to memory, or to an IO device, what
happened in the high order 8 bits wasn't important. It didn't matter if it
was sign extended or not. In those days, use of 8 bit signed ints was more
common because of the size of machines (64K of memory was possible) - today
we have so much memory we would never bother to use a signed 8 bit variable
just to save memory - we use signed 32 variables even when all we do is
count from 1 to 10. The design trade off was whether it was better to make
the byte move signed or unsigned. If unsigned, the programmer would have
to use two more instructions to do the sign extend (a test, and a bit set).
But if the hardware did the sign extend by default, and the programmer
didn't want it, all they would have to do is add an unconditional bit
clear. So, given the fact that when doing 8 bit operations, it made no
difference which way it worked, and when doing 8 bit to 16 bit conversion,
one default required 2 extra instructions to do the inverse, and the other
default only required 1 extra instruction, they picked the default that
made the inverse easier.
If C had made chars unsigned by default, it would have ended up generating
a lot of extra code to constantly undo the sign extension every time a char
was returned from a function since all function returns were promoted to
ints in those days. So C simply followed the convention of the very
limited PDP-11 hardware of those early days.
So now, we have it in Java, even though it really makes no sense at all in
our modern environment to be doing it - except for the advantage of
backward compatibility (which is important).
--
Curt Welch http://CurtWelch.Com/
email***@***.com http://NewsReader.Com/
|
| |
|
| |
 |
Mike Schilling

|
Posted: 2007-9-9 13:57:00 |
Top |
java-programmer >> casting from int to byte problem
"Arne Vajh鴍" <email***@***.com> wrote in message
news:46e35ac4$0$90262$email***@***.com...
> Mike Schilling wrote:
>> "Hunter Gratzner" <email***@***.com> wrote in message
>>> Get a Java book. Bytes in Java are signed.
>>
>> Which was, by the way, a bad idea.. I've never seen a program that wants
>> to do signed arithmetic on bytes. I've seen lots that assemble bytes
>> into chars and ints by shifting and or-ing, which would be much simpler
>> and more reliable if the damned things didn't sign-extend.
>
> C# got that one right: int, uint, byte and sbyte.
With int (signed) and byte (unsigned) being the ones commonly used, yes,
they did.
|
| |
|
| |
 |
Roedy Green

|
Posted: 2007-9-9 16:42:00 |
Top |
java-programmer >> casting from int to byte problem
On Sun, 9 Sep 2007 00:04:03 +0200, "buu" <email***@***.com> wrote, quoted or
indirectly quoted someone who said :
>it looks like I have a strange problem.
see http://mindprod.com/jgloss/unsigned.html
http://mindprod.com/applet/converter.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
ram

|
Posted: 2007-9-9 19:25:00 |
Top |
java-programmer >> casting from int to byte problem
email***@***.com (Curt Welch) writes:
>bytes are signed in C
ISO/IEC 9899:1999 (E), 6.2.5, #15, Sentence 2:
籘he implementation shall define char
to have the same range, representation,
and behavior as either signed char
or unsigned char.?
|
| |
|
| |
 |
Lew

|
Posted: 2007-9-9 20:20:00 |
Top |
java-programmer >> casting from int to byte problem
Curt Welch wrote:
>> they picked the default that
>> made the inverse easier.
email***@***.com wrote:
> ITYM "obverse"; inverse has a narrower meaning.
"Obverse" means either "front" / "facing" or "corresponding". It's most
common use is in numismatics. It is unlikely that's what Curt meant, as I
read his post.
--
Lew
|
| |
|
| |
 |
Lew

|
Posted: 2007-9-10 1:34:00 |
Top |
java-programmer >> casting from int to byte problem
Andreas Leitgeb wrote:
> Lew <email***@***.com> wrote:
>> email***@***.com wrote:
>>> ITYM "obverse"; inverse has a narrower meaning.
>> "Obverse" means either "front" / "facing" or "corresponding". It's most
>> common use is in numismatics. It is unlikely that's what Curt meant, as I
>> read his post.
>
> Don't tell us you're calling our twisted nebulous a liar! Don't you dare ... ;-)
Please, I'm doing nothing of the sort.
I am simply expressing my interpretation of Curt's message. Interpretation is
by nature subjective, albeit rooted in reality. It is certainly possible for
me to interpret Curt's message differently from nebulous without in any way
calling anyone a liar, or even necessarily making them wrong, since I might
be. (Of course, I'm not in this case.)
I just don't think Curt meant "obverse",
<http://en.wiktionary.org/wiki/obverse>,
since it doesn't fit the argument that he was making. I think I know what he
means by "inverse". It's mathematical, as in, "Expanding from 8 to 16 bits is
the inverse of collapsing from 16 to 8 bits." In that sense it makes sense,
at least to me.
--
Lew
|
| |
|
| |
 |
curt

|
Posted: 2007-9-10 2:01:00 |
Top |
java-programmer >> casting from int to byte problem
Lew <email***@***.com> wrote:
> Andreas Leitgeb wrote:
> > Lew <email***@***.com> wrote:
> >> email***@***.com wrote:
> >>> ITYM "obverse"; inverse has a narrower meaning.
> >> "Obverse" means either "front" / "facing" or "corresponding". It's
> >> most common use is in numismatics. It is unlikely that's what Curt
> >> meant, as I read his post.
> >
> > Don't tell us you're calling our twisted nebulous a liar! Don't you
> > dare ... ;-)
>
> Please, I'm doing nothing of the sort.
>
> I am simply expressing my interpretation of Curt's message.
> Interpretation is by nature subjective, albeit rooted in reality. It is
> certainly possible for me to interpret Curt's message differently from
> nebulous without in any way calling anyone a liar, or even necessarily
> making them wrong, since I might be. (Of course, I'm not in this case.)
>
> I just don't think Curt meant "obverse",
> <http://en.wiktionary.org/wiki/obverse>,
> since it doesn't fit the argument that he was making. I think I know
> what he means by "inverse". It's mathematical, as in, "Expanding from 8
> to 16 bits is the inverse of collapsing from 16 to 8 bits." In that
> sense it makes sense, at least to me.
I guess I should be more careful with my word usage. :)
I don't know if "obverse" is better or worse than "inverse" in what I wrote
but I also don't really care. I was just making the point that the
designers of the PDP-11 had to pick between two different behavior options
(signed or unsigned) when moving a byte to a 16 bit register and I tried to
show there were some rational reasons for picking signed behavior instead
of picking unsigned behavior. I just thought some people in the group
might not know this part of the history of signed bytes and might like to
know about it.
--
Curt Welch http://CurtWelch.Com/
email***@***.com http://NewsReader.Com/
|
| |
|
| |
 |
Mike Schilling

|
Posted: 2007-9-10 2:11:00 |
Top |
java-programmer >> casting from int to byte problem
<email***@***.com> wrote in message
news:email***@***.com...
> On Sep 9, 12:00 am, email***@***.com (Curt Welch) wrote:
>> I don't know the actual history of what happened in Java, but I assume
>> Java
>> just copied the C and C++ convention of chars being signed.
>
> ISTR char signedness actually being mentioned as implementation-
> dependent somewhere.
You are correct. Both C and C++ have three distinct types:
char
unsigned char
signed char
where "char" must act the same as one of the other two, but it's
implementation-dependent which one that is..
As Curt goes on to explain, bytes were treated as signed in PDP-11 (and
later VAX) machine language. Since these were for many years the most
common C (and especially Unix/C) platforms [1], it became common to think
of C chars as signed. I have no idea how influential this was on Java's
byte type.
1. One of the popular mantras for teaching portable C programming being "The
whole world isn't a VAX!".
|
| |
|
| |
 |
Arne Vajh鴍

|
Posted: 2007-9-10 8:42:00 |
Top |
java-programmer >> casting from int to byte problem
Mike Schilling wrote:
> As Curt goes on to explain, bytes were treated as signed in PDP-11 (and
> later VAX) machine language. Since these were for many years the most
> common C (and especially Unix/C) platforms [1], it became common to think
> of C chars as signed. I have no idea how influential this was on Java's
> byte type.
>
> 1. One of the popular mantras for teaching portable C programming being "The
> whole world isn't a VAX!".
A lot of VAX'es did not have a good C compiler at all (VAX C 3.x on
VMS had a rather bad reputation).
Arne
|
| |
|
| |
 |
Mike Schilling

|
Posted: 2007-9-10 9:35:00 |
Top |
java-programmer >> casting from int to byte problem
"Arne Vajh鴍" <email***@***.com> wrote in message
news:46e492c3$0$90270$email***@***.com...
> Mike Schilling wrote:
>> As Curt goes on to explain, bytes were treated as signed in PDP-11 (and
>> later VAX) machine language. Since these were for many years the most
>> common C (and especially Unix/C) platforms [1], it became common to
>> think of C chars as signed. I have no idea how influential this was on
>> Java's byte type.
>>
>> 1. One of the popular mantras for teaching portable C programming being
>> "The whole world isn't a VAX!".
>
> A lot of VAX'es did not have a good C compiler at all (VAX C 3.x on
> VMS had a rather bad reputation).
Vaxen running BSD had a pretty good one :-)
The problems with the VMS compilers, to my mind, are outgrowths of the fact
VMS and Unix are quite different. The Unix emulation (e.g. open(),
create(), fork()) didn't work very well, and the fact that VMS defaulted to
record-oriented rather than stream files made stdio difficult to use. Also,
while the VMS-specific features (globalref/globaldef, #include from text
libraries, etc.) worked fine, they looked decidedly odd to anyone who was a
C programmer rather than a VMS programmer.
|
| |
|
| |
 |
Arne Vajh鴍

|
Posted: 2007-9-10 9:49:00 |
Top |
java-programmer >> casting from int to byte problem
Mike Schilling wrote:
> "Arne Vajh鴍" <email***@***.com> wrote in message
> news:46e492c3$0$90270$email***@***.com...
>> Mike Schilling wrote:
>>> As Curt goes on to explain, bytes were treated as signed in PDP-11 (and
>>> later VAX) machine language. Since these were for many years the most
>>> common C (and especially Unix/C) platforms [1], it became common to
>>> think of C chars as signed. I have no idea how influential this was on
>>> Java's byte type.
>>>
>>> 1. One of the popular mantras for teaching portable C programming being
>>> "The whole world isn't a VAX!".
>> A lot of VAX'es did not have a good C compiler at all (VAX C 3.x on
>> VMS had a rather bad reputation).
>
> Vaxen running BSD had a pretty good one :-)
>
> The problems with the VMS compilers, to my mind, are outgrowths of the fact
> VMS and Unix are quite different. The Unix emulation (e.g. open(),
> create(), fork()) didn't work very well, and the fact that VMS defaulted to
> record-oriented rather than stream files made stdio difficult to use. Also,
> while the VMS-specific features (globalref/globaldef, #include from text
> libraries, etc.) worked fine, they looked decidedly odd to anyone who was a
> C programmer rather than a VMS programmer.
I was a VMS programmer so they made perfectly sense to me.
No I am talking about bugs that require code to be compiled with
/NOOPT, not being ANSI compliant etc..
Arne
|
| |
|
| |
 |
nebulous99

|
Posted: 2007-9-11 10:55:00 |
Top |
java-programmer >> casting from int to byte problem
On Sep 9, 8:20 am, Lew <email***@***.com> wrote:
> Curt Welch wrote:
> >> they picked the default that
> >> made the inverse easier.
> email***@***.com wrote:
> > ITYM "obverse"; inverse has a narrower meaning.
>
> "Obverse" means either "front" / "facing" or "corresponding". It's most
> common use is in numismatics. It is unlikely that's what Curt meant, as I
> read his post.
I call excessive pedantry.
He was describing the choice among two alternatives, sign-extending
and not sign-extending. They clearly aren't "inverses" in the usual
sense. "Obverse" does seem to fit better. If you know of a still
better word following the same pattern by all means suggest it;
otherwise leave me the fuck alone. :P
|
| |
|
| |
 |
Lew

|
Posted: 2007-9-11 13:04:00 |
Top |
java-programmer >> casting from int to byte problem
Lew wrote:
> what Curtis said.
I apologize. I meant, "what Curt said."
--
Lew
|
| |
|
| |
 |
nebulous99

|
Posted: 2007-9-11 16:09:00 |
Top |
java-programmer >> casting from int to byte problem
On Sep 11, 12:56 am, Lew <email***@***.com> wrote:
[snip attack post]
Stop attacking me.
He was not referring to widening versus narrowing; he was referring to
widening with sign extension vs. widening without sign extension.
Your whole vicious attack post is predicated on a wrong assumption,
which is easy to check if you'd bother to read the original post.
Now leave me alone.
|
| |
|
| |
 |
Lew

|
Posted: 2007-9-11 23:37:00 |
Top |
java-programmer >> casting from int to byte problem
Twisted wrote:
>Lew wrote:
> [snip attack post]
:-)
> Stop attacking me.
If you'd bothered to read my post you would see that I said nothing about you
at all, much less attacked you.
> He was not referring to widening versus narrowing; he was referring to
> widening with sign extension vs. widening without sign extension.
>
> Your whole vicious attack post is predicated on a wrong assumption,
> which is easy to check if you'd bother to read the original post.
Here's an excerpt from the original post about "inverse":
> When you did a byte move
> into a register (registers were all 16 bits) it was sign extended by
> default.
...
> If you did a byte move to the register, and performed math on it
> (16 bit), and did a byte move back to memory, or to an IO device, what
> happened in the high order 8 bits wasn't important.
...
> So, given the fact that when doing 8 bit operations, it made no
> difference which way it worked, and when doing 8 bit to 16 bit conversion,
> one default required 2 extra instructions to do the inverse, and the other
> default only required 1 extra instruction, they picked the default that
> made the inverse easier.
From that last sentence, it is clear that the two options of "sign extend" or
"no sign extend" are choices to be applied to the same "inverse" operation,
therefore he was not talking about "not sign extend" as the inverse of "sign
extend". Also, it is clear that nothing in his comment was an obverse of
anything else. From the context, I concluded that "when doing 8-bit
operations" referred to the narrowing of 16 to 8 bits, so clearly "when doing
8 bit [sic] to 16 bit [sic] conversion" is intended to be the "inverse"
operation under discussion.
So, despite your vicious inflammatory attack ("if you'd bother"), it is clear
that I did, indeed, read the original post, and that I drew my conclusions
from it. Conclusions, not assumptions, in that they are the product of
reasoning supported by evidence, /a posteriori/.
Anyhow, even if I'm wrong, which I might be, about what Curt meant by
"inverse", there is no way that "obverse" applies.
I notice that in your /ad hominem/ post you completely neglected to address
that point, the central point that I made. Hmm.
So if you have a better choice than "inverse" that is not so clearly
inappropriate and inapplicable as "obverse", let's hear it. I'm satisfied
that I understood the sense of the post, whether "inverse" is exactly right or
not, and I'm simply seeking to illuminate the process by which I arrived at my
understanding. I respect your right to disagree and see it differently.
--
Lew
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- tridimensional view in B&WI made a program with java3d and I can print views from it.
I want to print only the lines like the wireframe but without hide lines
Have you same Ideas??
zeno
- 2
- Extract all dates from text documentHi,
1) I have a bunch of documents, some of which may contain dates.
2) For each document, I would like to identify all existing dates.
3) The dates exist in multiple formats.
Example: (May 5, 1932), (5,5,1932), (5/5/1932), (5-5-1942) etc.
4) I would like to process a single document very quickly. In other
words, i'm looking for a time efficient solution.
Are there any existing parsers that take in a generic text string and
return a collection of dates found in the text string?
Are there any existing flex/cup files that perform this task?
Thanks.
- 3
- OLAP & OLTP schemas and Java App ServerHi,
(I hope this is the right group to post this. If not I apologize and
would appreciate pointers.)
We have a Websphere Applicaiton server for our application. We plan to
have a database that is part relational and part star on DB2 UDB. We
will need an OLAP tool and may use BRIO.
Some questions on this approach:
1. What is the best way to access the OLAP schema from Java (we plan
to use hibernate but are concerned about its suitability for star
schemas).
Some things that I could think of are:
- Use hibernate on the star schema (not sure if this is the best)
- Create as many materialized views as necessary and use hibernate
- Use java objects running on the DBs JVM (db optimized jvm implying
better performance?)
2. Is Brio the right tool to use for this scenario?
I ask because we can't have direct integration with the J2EE
applicaiton server (We have to give the user a different login page to
brio to see the reports. But they may take hours to produce.)
3. What are your experiences in combining star and relational tables
in the same database?
4. Any thoughts on using DB2 OLAP server? Apparently it has reporting
capabilities and Java support, but unsure if it has any advantages
over Brio.
Thanks in advance,
Naga
- 4
- for wanids: very enticing tunes - gudri wonhe - (1/1)On Tue, 06 Sep 2005 23:52:20 +0200, bone wrote:
> Hello all?
Oh, ..you too?
This sh*t is commonly known as SPAM. Stop it, before I
have to send the boys around.
--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Who gave you the power? WE DID!!"
Alice Cooper 'Department of Youth'
- 5
- about static variableViv,
Viv wrote:
>I mean to say that the objects will get garbage collected but not the
>static variables. Class will remain in memory till the JVM shutdown.
>
>Roedy wrote :
>The only way you can recover the ram from a static class object is to
>load it with a custom classloader, then drop even the reference to the
>class loader.
>
>You can try what Roedy said.
What means "recover the ram from a static class object"? What do you mean
"recover"? I think there is not static class object -- only static class
members.
Do you know where can I find a sample dealing with how to write a customized
ClassLoader with the functions as you mentioned?
regards,
George
--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200511/1
- 6
- Windows styleHI! I'm developing an application that is going tu run on windows XP
Professinal, and I want that the buttons, combo boxes etc every
component that I use, looks like a windows component, not like a swing
button for example. I don`t know if anyone understands me.
I'm using NetBeans IDE, (using jdk 1-4-2).
When I am designing my form and I drag and drop a button for example,
it has a rounded shape, like a normal windows button, but when I
compile and run my project, the button is not rounded anymore, and
doesn't looks like a Windows Button.
What can I do??
Thaks a lot!!
- 7
- Printing using CUPS in Linux and Java 1.5According to the blurb one of the upgrades in 1.5 is the ability to
print using CUPS in Linux. Does anyone have this working? I cannot get
my Jva application to communicate with CUPS.
Thanks,
Alan
- 8
- How to Fail at Software DevelopmentHello,
The book "How to Fail at Software Develoopment" is about all the
strange and funny things people do in the name of developing software.
I worked in software development for over 20 years and found silly
things that were being done in the name of software development were
being repeated again and again. As a matter of fact, most things that
cause software projects to fail are forever being repeated. And you
can spot the symptoms if you know what to look for.
Most people running software projects don't have much software
experience, so their inventions are usually not new. They rediscover
the same mistakes over and over again. It turned out to be a book of
very funny scenarios--some I lived through, and some were lived
through by others.
Those who don't know the history of software failure are doomed to
repeat it. You can find the book on Amazon or wherever.
Arthur Griffith
"How to Fail at Software Development"
http://www.anchorpointbooks.com
- 9
- Action or Subclass method?I need to know which is the PROPER way of handling this situation:
I would like to be able to cascade all the JInternalFrames in a
JDesktopPane.
Should I create a
1) cascade() method in a subclass of JDesktopPane? or
2) create a CascadeAction (a subclass of AbstractAction) and pass a
reference of the JDesktopPane?
Both ways work. HOWEVER, which is the PROPER Object Oriented solution?
- 10
- How to listen out for a stream of data coming from (web)serverHello
I have an applet that connects to a server (same location as web server) and
connects to a server on a socket. This all works fine for sending commands
to this server. But the server can send data to the client at any moment in
time. So how do I listen out for the activity? do I launch a separate thread
that sits listening for incoming data?
What is the way to do it?
Angus
- 11
- reading Mouse MOVE events without moving pointerHi,
Does anyone know of way of setting up a java app so that a instead of
mouse movements being used to update the pointer, the mouse move could
be used to update, say, the viewport of a document?
An example in more detail;
what I want to do is use the mouse MOVE event that is caused by the
movement of the mouse, but not update the pointer position (I would
like the pointer to remain still or be invisble) but to allow me to
update the viewport on a document. ie, user presses a 'trigger' key
to put the code into a receptive mode, then all subsequent mouse
movements (triggering mouse MOVE events) can be captured and used to
update the viewport location- ie, mouse moves left, pointer remains
still, viewport moves left.
I don't know if this is possible due to the OS independance that java
has. Maybe a solution involves the glass-pane in some (I am not
familiar with the glass- yet. It is one of my avenues to search...)
Thanks for any ideas... mucho thanks for any code examples....
M.
- 12
- Oracle JDBC and AppletHello
I have an applet which download files to local computer from database
(files are saved as BLOB fileds).
Applet is signed bud when I want to get connection to Oracle (method
getConnection from OracleDataSource) i have following error:
java.security.AccessControlException: access denied
(java.util.PropertyPermission oracle.jserver.version read)
Applet working only when I running it from JBuilder. Otherwise the
error comes.
I can't see other posibility than using applets because number of
files is very big. For example 20 000 to take at once, so the normal
download method via http is not good here. Also the size of one
download may be up to 1GB.
Thanks for help
Bartek
- 13
- openGL java and X - server: a crashHy folks,
I didn't know exactly where to post, in the end I decided for this
forum, since we are talking about java, GL4java on linux environment.
We are developing a java interface for the GIS GRASS
(http://grass.itc.it) using GL4java calls for raster visualization.
I'm not the developer that works on the GL part. On his computer
everything compiles and works alright.
When I run the application, when the first GL call comes (i assume
so), the X server shuts down and restarts. In the /var/log/message the
only line that defines what happened, is:
kdm[2232]: Server for display :0 terminated unexpectedly
Nothing else!
I use Suse 9 (I upgraded from 8.2 hoping to solve that problem, but no
way) which a Toshiba Satellite 5200-801 which loads an NVIDIA GeForce4
460 Go.
I downloaded and installed the drivers supplied by Nvidia and they
work perfect for everything but this.
I know NVIDIA to be unstable with linux nowadays, but I can't work
this way!
Has anyone encountered the same or similar problem?
Regards,
Andrea
- 14
- JNI QuestionOn Mar 2, 2:17 pm, Gordon Beaton <email***@***.com> wrote:
> On 2 Mar 2007 08:05:22 -0800, Edsoncv wrote:
>
> > If I have only the C part, I would cast the "native1" object, pass
> > to "setup" and cast back the object, but since the setup function is
> > called from java, I don't know how to access native1 object from
> > "setup". Is it possible?
>
> Of course.
>
> Either store it someplace in the native code where it's visible to
> both methods (i.e. not as a local variable in solve() like your
> example).
>
> Or, remembering that even native methods have return values, return it
> to the caller (cast to jlong) so that it can be passed back to the
> next method, where you cast it back to the appropriate pointer type
> before attempting to use it.
>
> /gordon
>
> --
> [ don't email me support questions or followups ]
> g o r d o n + n e w s @ b a l d e r 1 3 . s e
Thanks Gordon, I think I'll pick the second option.
- 15
- applet is not initiallising.what's wrong with this source code.
it is showing the message applet is not initiallising.
--------------------------------------------------------------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LinearSearch extends JApplet implements ActionListener
{
JLabel enterLabel;
JTextField enter;
JTextArea outputArea1, outputArea2;
JButton search;
String output;
int a[];
public void init()
{
a=new int[Integer.parseInt(JOptionPane.showInputDialog("how many
numbers, you want to input:"))];
for(int i=0; i<a.length; ++i)
a[i]=Integer.parseInt(JOptionPane.showInputDialog("enter the
integer number."));
output="numbers are:\n";
for(int i=0; i<a.length; ++i)
output += " "+a[i];
for(int i=1; i<a.length; ++i)
for(int j=0; j<=a.length-1; ++j)
if(a[j]>a[j+1])
{
int t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
output += "\n\nnow numbers are in ascending order.\n";
for(int i=0; i<a.length; ++i)
output += " "+a[i];
Container c=getContentPane();
c.setLayout(new FlowLayout());
outputArea1=new JTextArea();
c.add(outputArea1);
outputArea1.setText(output);
enterLabel=new JLabel("enter the number, you want to search.");
c.add(enterLabel);
enter=new JTextField(10);
enter.addActionListener(this);
c.add(enter);
outputArea2=new JTextArea();
c.add(outputArea2);
search=new JButton("new search");
search.addActionListener(this);
c.add(search);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == enter)
{
int subscript=linearSearch(a,
Integer.parseInt(e.getActionCommand()));
if(subscript != -1)
outputArea2.setText("number found at position no. "+subscript+"
in the sorted list.");
else
outputArea2.setText("Sorry!!! number not found. \n\nhave a look
on new search");
}
else
JOptionPane.showMessageDialog(null, "Please click on the Applet
menu on the menu Bar.\n"+"click on the clone option.\n"+"Repeat the
search process again.");
}
public int linearSearch(int b[], int k)
{
for(int i=0; i<b.length; ++i)
if(b[i] == k)
return i;
return -1;
}
}
---------------------------------------------------------------------------------------------------------------------------------------
it is asking for no. of elements. and input the numbers. but after then
applet is not able to initialise.
|
|
|