java

Error: Servlet Jar not Loaded

I get the following error: INFO: validateJarFile(C:\dev\server\tomcat6\webapps Sempedia\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, sectoin 9.7.2. Offending class: javax/servlet/Servlet.class The existing resources out there say it is due to a conflict with the servlet.jar or in my case named servlet-api....

abstracting code from two methods in Java, maybe use delegates?

I have two methods that do essentially the same thing, just with different types. I want to abstract out this functionality to some generic method and I think I could do it easily in C# with delegates, but I don't know the equivalent in Java. I'm just showing two of the methods here, but there are several (like eight) different makeWha...

Problem with static attributes

My problem is that I'm working on a project that requires me to run multiple instances of someone elses code which has many static attributes/variables, which causes all the instances to share those resources and, well, crash. I can run multiple instances of this other person's program if I create a .jar file off of it and open it multip...

How to sort hashmap?

Hi All ! I have hashmap and its keys are like "folder/1.txt,folder/2.txt,folder/3.txt" and value has these text files data. Now i am stucked. I want to sort this list. But it does not let me do it :( Here is my hashmap data type: HashMap<String, ArrayList<String>> following function work good but it is for arraylist not for hashma...

google maps api

How do you access google maps API from a Java application? ...

does spring provide 2 mvc platforms, grails and spring mvc?

Just reading spring in action, and I know there is a chapter on MVC that I havent' got to yet. I also read about grails, is that another framework or built on top of spring? ...

glassfish error

SEVERE: javax.naming.NamingException: Lookup failed for 'jdbc:mysql://localhost:3306/sample ' in SerialContext [Root exception is javax.naming.NameNotFoundException: jdbc:mysql:] what to do to rectify? i am running jsp code in netbeans and i am using mysql as dbms ...

Instance variable initialization in java

Hi I have doubt in instance variable initialization in java.I have seen different developers initializing varibles differently.In the below sample codes what is better way.Do we have any advantage of initializing variables inside the constructor? .. Example 1 code is easy to read.Can anyone clarify this..... Example 1: class A { B b...

trying to retrieve file from blobstore and send it as mail attachment using google app engine

I am trying to design an application that would require me to retrieve data stored in blobstore and send it as attachment. Does google app engine allow this? From the documentation, i could not find a way to retrieve data from blobstore for processing within the app.. can someone please tell me how to accomplish this? Code examples and/...

How to write console output to a txt file

I have tried to write the console output to a txt file using this code suggestion (http://www.daniweb.com/forums/thread23883.html#) however I am not succeed. Whats wrong? try { //create a buffered reader that connects to the console, we use it so we can read lines BufferedReader in = new BufferedReader(new InputStreamReader(...

Challenging Multithreading Problems

Is there some resource for challenging multi-threading problems? Would like to pose these to interviewees if possible. Tired of asking the same wait-notify questions that everyone gets right these days, but can't visualise a real scenario where multi-threading was employed. ...

How to turn static methods into non-static. Small explanation/examples related to java oop

Hello. I cant get how to use/create oop code without word static. I read Sun tutorials, have book and examples. I know there are constructors, then "pointer" this etc. I can create some easy non-static methods with return statement. The real problem is, I just don't understand how it works.I hope some communication gives me kick to move ...

JUnit4 in Eclipse

I'm trying to run some JUnit test units in eclipse 3.5, but with no luck at all. JUnit3 works fine. When I create the JUnit4 Test unit, eclipse offers to add the JUnit library to the class-path. I accept, but when i check to see if it was added in the project's properties panel, I can see JUnit4 was added, but no JARS where included. I...

Remote EJB3 invocation

Are remote EJB calls, made from the same application server, always optimized as local, in-memory calls, and is serialization of data skipped in this scenario? In other words, is it valid to work with remote EJBs all the time, thus achieving decoupling between application components, even if two+ EJB modules are deployed in the same co...

Session class in NetBeans IDE6.7

can we use Session class in Netbeans IDE 6.7.do we have to include any package for it.also if anybody can provide a sample example related to this question. ...

How to save a file with an incrementing suffix - file1, file2, etc.

Scenario: I save my drawing with a file name as picture. After a while I made some changes on the file picture and save it again. Since both file have the same name, is it possible that the new file automatically saved as picture*1* without need to manually change the file name in the program? ... I means automatically add number at th...

A problem with parametrized return value type

Hello, I am somewhat new to the Java Generics feature. Can you please help me to figure out why the code snippet below does not work: interface Response {} interface Request<T extends Response> {} class TestResponse implements Response {} class TestRequest implements Request<TestResponse> {} <T extends Response> T foo(Request<T> b) ...

Magic Exception thrower without declaring throws Exception.

I want a method that can throw any Throwable including sub classes of Exception. Ive got something that takes an exception, stashes it in a thread local, then invokes a class.newInstance. That class ctor declares that it throws Exception then takes the threadlocal and throws it. Problem is it does not work for the two declared Exceptions...

MySQL Connection Error with JSP

Hello, I am trying to connect to mysql database from jsp page. The connection code is as below InitialContext ic=new InitialContext(); DataSource ds=(DataSource)ic.lookup("jdbc:mysql://localhost:3306/"); Connection con=ds.getConnection(); Statement stmt = con.createStatement(); when i open the page i get the foll...

Which programming languages can I use on Android Dalvik?

In theory, Dalvik executes any virtual machine byte code, created for example with the compilers of AspectJ ColdFusion Clojure Groovy JavaFX Script JRuby Jython Rhino Scala Are there already working versions of bytecode compilers for Dalvik available for other languages than Java? ...