Is it possible to use a for-each loop in Java and somehow still get the index of the iteration?
for (Object obj : ListOfObject) {
// I want to know the index of obj!
}
Frustrated in finding the .jar -balls like google collections or "package org.apache.commons.io;". Is there some utility to get them fast like the style-"apt-get source app"? "get-java-jar-ball-3rd source apache commons"?
What would be the best way (ideally, simplest) to convert an int to a binary string representation in Java?
For example, say the int is 156. The binary string representation of this would be "10011100".
Hi,
I am developing an application in Netbeans, and it is using JavaDB. I can connect to it and execute queries without issues, but for some reason, the "Output - JavaDB Database Process" pane within Netbeans keeps displaying
Security manager installed using the Basic server security policy.
Could not listen on port 1527 on host localhost:
java.net.BindException: Address already in use
How do I find out what process is already using, or bound to that port?
On Ubuntu Karmic, Netbeans 6.7.1
Hi is there any tool available in Java world that will parse/read a source file and pull SQL statements out in to a text file. This is a complex task given that you can write SQL statements in different fashion within the source (ex: using + sign or using .append()) or even conditional building of SQL.
You launch a java program from a console (maybe using a .bat script).
I don't want the console to remain visible, I want to hide it.
Is there a simple way to do this ? Without JNI ?
Thanks.
I have an application where I need to check for a file which may be created dynamically during my execution, I will give up after some MAX time where the file has yet to show up. I wanted to know if there was a more efficient method in Java of checking for the file other than polling for it and then sleeping every X seconds? If not what would be the most efficient manner of doing this?
Hi i have a column (type date).I want to insert custom date and time without using Preparedstatement .i have used
String date = sf.format(Calendar.getInstance().getTime());
String query = "Insert into entryTbl(name, joinedDate, ..etc) values ("abc", to_date(date, 'yyyy/mm/dd HH:mm:ss'))";
statement.executeUpdate(query);
but am getting literal doesnot match error. so even tried with "SYSDATE".Its inserting only date not time.So how to insert the datetime using java into oracle?please any one help..
Hello,
I have a problem. I need to host many (tens, hundreds) of small identical JAVA web applications that have different loads during one time. I want to use Glassfish V3. Do I need to use a load balancer and clusters or something else? Advise where can I find information about similar problems and their solutions...
Best regards,
Alexey.
Is it possible to set a default behaviour for custom (non-native) methods/functions in Java?
For example, I would like to change the default "Function" to do a System.out.println("message") whenever called.
So, when a custom method/function is being created:
public String testMethod()
{
//custom code
}
it should execute the newly added default behaviour (in this case the system output), before the custom code is run.
Even if this would be a bad excercise, is it possible? Maybe by extending the function class or something?
I'm looking for some simple tasks like listing all the running process of a user, or kill a particular process by pid etc. Basic unix process management from Java. Is there a library out there that is relatively mature and documented? I could run a external command from the JVM and then parse the standard output/error but that seems like a lot of work and not robust at all. Any suggestions?
I have multiple Java projects in Eclipse. I would like to reuse some classes in my new project from my old project. What is the best way to do that in Eclipse?
I.e. is it possible to add another "project folder" to the build-path for my new project?
Lazy programmer alert. :)
Cassandra stores column values as bytes (Java example). Specifying a LongType comparator compares those bytes as a long. I want the value of a long into a Cassandra-friendly byte[]. How? I poked around for awhile. I think you people can help me faster.
I've created java webservices and clients using Netbeans. However, the clients seem to have the WSDL already 'built-in'.
Is there an easy way of making my client fetch and parse the WSDL code upon execution, so that if the webservice moves to another server, the client is just invoked with a different commandline argument for where to find the webservice?
Hi all,
I want to genrate following JSON dataobject using org.json.simple.JSONObject, how to do it in java?
{
friends : [
{
name: 'David',
interests: 'Cooking',
},
{
name: 'Charles',
interests: 'Hiking',
},
{
name: 'Mary',
interests: 'Football',
},
]
}
If code snipet is provided then that will be really helpful!
Regards,
Abhi
Hi,
We have discussion in my job place about question (We use 1 of the php frameworks):
Why program with php frameworks big web application if it can be done better with rubi on rails, python or java?
Please say our opinion
thanks
I want to write a plug-in which tracks the updates to a text file and stores them in a separate file.
Should I first write a simple java program which does this and then try to convert it into a plug-in?
In Java, an array IS AN Object. My question is... is an Object constructor called when new arrays is being created? We would like to use this fact to instrument Object constructor with some extra bytecode which checks length of array being constructed. Would that work?
Super constructor invocation definition:
[Primary.] [NonWildTypeArguments] super ( ArgumentListopt ) ;
A super constructor call can be prefixed by an Primary expression. Example (taken from JLS):
class Outer {
class Inner{ }
}
class ChildOfInner extends Outer.Inner {
ChildOfInner() {
(new Outer()).super(); // (new Outer()) is the Primary
}
}
Does a Primary expression exist that makes the call to super() the invocation of a constructor of the calling class? Or Java prevents that?
is there a dictionary i can download for java?
i want to have a program that takes a few random letters and sees if they can be rearanged into a real word by checking them against the dictionary
I am using JNI to initialize classes in my jar files present at the classpath. But created executable uses java and displays ugly command prompt when my program starts. I want to configure my JNI to use javaw instead. How can I achieve it?
Platform: Windows 7