Search Results

Search found 33640 results on 1346 pages for 'java generics'.

Page 81/1346 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • Exception in thread "main" java.lang.NoClassDefFoundError: while running .bat file

    - by Manu
    hi, i have bat file like below with name (myBat.bat) @echo off set CLASSPATH=%CLASSPATH%;C:\Documents and Settings\nchakk\Desktop\3611 java\ javac packbat.inter.java javac packbat.samplepack.java java packbat.inter java packbat.samplepack pause //interface "inter" inside package packbat package packbat; public interface inter { int i=10; } //my main()class inside package packbat package packbat; public class samplepack implements inter { public static void main(String s[]) { System.out.println(i); } } after clicking that .bat file it diplay error like below Exception in thread "main" java.lang.NoClassDefFoundError: packbat/inter Caused by: java.lang.ClassNotFoundException: packbat.inter how to run tat .bat file without error. Pls reply ASAP.Thanks in advance

    Read the article

  • Java - getClassLoader().getResource() driving me bonkers

    - by Click Upvote
    I have this test app: import java.applet.*; import java.awt.*; import java.net.URL; public class Test extends Applet { public void init() { URL some=Test.class.getClass().getClassLoader().getResource("/assets/pacman.png"); System.out.println(some.toString()); System.out.println(some.getFile()); System.out.println(some.getPath()); } } When I run it from Eclipse, I get the error: java.lang.NullPointerException at Test.init(Test.java:9) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Classpath (from .CLASSPATH file) <classpathentry kind="src" path="src"/> In my c:\project\src folder, I have only the Test.java file and the 'assets' directory which contains pacman.png. What am I doing wrong and how to resolve it?

    Read the article

  • Can I connect to SQL Server using Windows Authentication from Java EE webapp?

    - by KG
    I am currently investigating how to make a connection to a SQL Server database from my Java EE web application using Windows Authentication instead of SQL Server authentication. I am running this app off of Tomcat 6.0, and am utilizing the Microsoft JDBC driver. My connection properties file looks as follows: dbDriver = com.microsoft.sqlserver.jdbc.SQLServerDriver dbUser = user dbPass = password dbServer = localhost:1433;databaseName=testDb dbUrl = jdbc:sqlserver://localhost:1433 I have zero problems with connecting to a SQL Server database in this fashion when using SQL Server authentication. Is there any way I can retrieve the credentials of the user's Windows Authentication and use that authentication for SQL Server? UPDATE: I know in ASP.net there is a way to set up Windows Authentication for access to the webapp, which is exactly what I am looking for, except I want to pass that token off to SQL Server for access to the database.

    Read the article

  • java vs python. In what way is Java Better?

    - by oxinabox.ucc.asn.au
    What are the advantages of Java over Python? What are the disadvantagesof Python, over Java? Why isn't Java more like Python? Like why don't java have an command line iterpretor? I beleive Java must have some advantages, but...I'm yet to see them. Logically all languages have an advantage afaict: I learnt java before python, - a 6 month unicourse. I spend a couple of weeks using python (writting a script to make a C source file). I hated it at first (as it was so differnt from C). I realised I had fallen in love it it, when I noticed that when I went to do a follow on Java Course at uni, I'ld stopped giving my variables types, and was tryign to multiply strings.

    Read the article

  • Communication between java server and matlab client

    - by user272587
    I'd like to establish a server(Java)/client (Matlab) communication using socket. They can send messages to each other. An example shows how to do this in Java server and Java client, http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html. When I try to rewrite the client part in Matlab, I only can get the first message that the Java server sends and display it in the Matlab command window. When I type a message in the Matlab command window, I can't pass it to the Java Server. Jave code: kkSocket = new Socket("localhost", 3434); Matlab equivalent: kkSocket = Socket('localhost', 3434); Java code for client: out = new PrintWriter(kkSocket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream())); What would be a Matlab equivalent for this? Thanks in advance.

    Read the article

  • What should I learn to improve my Java skills ?

    - by hory.incpp
    Hello, I currently know Java SE and I want to learn something more 'enterprise'. I would like something more distributed (app server, server programming, web, content management system ...) but any suggestion is ok. There are many frameworks which I've heard: spring, hibernate, persistence, ejb, jsp, servlet, jsf, jboss, glassfish, ant etc etc etc etc. I'm very confused where to start. So the question is: Can somebody explain to me what actually there frameworks are; and which one should I start with ? Thank you.

    Read the article

  • Java newbie problem: package with private access

    - by HH
    Pack.java imports pack.TestPack; but it cannot access it. I cannot understand why it cannot access the class despite the import. Error Pack.java:7: TestPack() is not public in pack.TestPack; cannot be accessed from outside package System.out.println(new TestPack().getHello()); ^ 1 error Pack.java import pack.TestPack; import java.io.*; public class Pack { public static void main(String[] args){ System.out.println(new TestPack().getHello()); } } TestPack.java package pack; import java.util.*; import java.io.*; public class TestPack { private String hello="if you see me, you ar inside class TestPack"; public String getHello(){return hello;} TestPack(){} }

    Read the article

  • Java Prepared Statement Error

    - by Suresh S
    Hi Guys the following code throws me an error i have an insert statement created once and in the while loop i am dynamically setting parameter , and at the end i says ps2.addBatch() again while ( (eachLine = in.readLine()) != null)) { for (int k=stat; k <=45;k++) { ps2.setString (k,main[(k-2)]); } stat=45; for (int l=1;l<= 2; l++) { ps2.setString((stat+l),pdp[(l-1)]);// Exception } ps2.addBatch(); } This is the error java.lang.ArrayIndexOutOfBoundsException: 45 at oracle.jdbc.dbaccess.DBDataSetImpl._getDBItem(DBDataSetImpl.java:378) at oracle.jdbc.dbaccess.DBDataSetImpl._createOrGetDBItem(DBDataSetImpl.java:781) at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2450) at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1155) at oracle.jdbc.driver.OraclePreparedStatement.setString(OraclePreparedStatement.java:1572) at Processor.main(Processor.java:233)

    Read the article

  • Make a USB Device, Control It In Java

    - by yar
    I'm thinking about making a physical controller (device?) with knobs, buttons, and LEDs. I'd like to interact with it using Java (respond to the knobs, light up LEDs, etc). The reason I mention Java is two-fold: first, I know Java well1. Second, I've written the rest of the program I need to interface with in Java (though there are ways to talk to the Java program from another language). I would like the device to connect via USB and be (computer-)platform independent. I haven't the slightest idea of where to start, except to start reading the Arduino website. Is this my best/only option? Is there something better suited for communicating with Java? Note: I know that Arduino has something to do with Java (not sure what), but it seems like code must be written in a subset of C. How would I get moving on this topic? 1 - No laughter, please.

    Read the article

  • java.lang.NullPointerException exception in my controller file (using Spring Hibernate Maven)

    - by mrjayviper
    The problem doesn't seemed to have anything to do with Hibernate. As I've commented the Hibernate stuff but I'm still getting it. If I comment out this line message = staffDAO.searchForStaff(search); in my controller file, it goes through ok. But I don't see anything wrong with searchForStaff function. It's a very simple function that just returns the string "test" and run system.out.println("test"). Can you please help? thanks But this is the error that I'm getting: SEVERE: Servlet.service() for servlet [spring] in context with path [/directorymaven] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException at org.flinders.staffdirectory.controllers.SearchController.showSearchResults(SearchController.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) My spring-servlet xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <context:component-scan base-package="org.flinders.staffdirectory.controllers" /> <mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <tx:annotation-driven /> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:location="/WEB-INF/spring.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}" /> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" p:dataSource-ref="dataSource" p:configLocation="${hibernate.config}" p:packagesToScan="org.flinders.staffdirectory"/> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:viewClass="org.springframework.web.servlet.view.tiles2.TilesView" /> <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" p:definitions="/WEB-INF/tiles.xml" /> <bean id="staffDAO" class="org.flinders.staffdirectory.dao.StaffDAO" p:sessionFactory-ref="sessionFactory" /> <!-- <bean id="staffService" class="org.flinders.staffdirectory.services.StaffServiceImpl" p:staffDAO-ref="staffDAO" />--> </beans> This is my controller file package org.flinders.staffdirectory.controllers; import java.util.List; //import org.flinders.staffdirectory.models.database.SearchResult; import org.flinders.staffdirectory.models.misc.Search; import org.flinders.staffdirectory.dao.StaffDAO; //import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class SearchController { //@Autowired private StaffDAO staffDAO; private String message; @RequestMapping("/SearchStaff") public ModelAndView showSearchResults(@ModelAttribute Search search) { //List<SearchResult> searchResults = message = staffDAO.searchForStaff(search); //System.out.println(search.getSurname()); return new ModelAndView("search/SearchForm", "Search", new Search()); //return new ModelAndView("search/SearchResults", "searchResults", searchResults); } @RequestMapping("/SearchForm") public ModelAndView showSearchForm() { return new ModelAndView("search/SearchForm", "search", new Search()); } } my dao class package org.flinders.staffdirectory.dao; import java.util.List; import org.hibernate.SessionFactory; //import org.springframework.beans.factory.annotation.Autowired; import org.flinders.staffdirectory.models.database.SearchResult; import org.flinders.staffdirectory.models.misc.Search; public class StaffDAO { //@Autowired private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public String searchForStaff(Search search) { /*String SQL = "select distinct telsumm_id as id, telsumm_parent_id as parentId, telsumm_name_title as title, (case when substr(telsumm_surname, length(telsumm_surname) - 1, 1) = ',' then substr(telsumm_surname, 1, length(telsumm_surname) - 1) else telsumm_surname end) as surname, telsumm_preferred_name as firstname, nvl(telsumm_tele_number, '-') as telephoneNumber, nvl(telsumm_role, '-') as role, telsumm_display_department as department, lower(telsumm_entity_type) as entityType from teldirt.teld_summary where (telsumm_search_surname is not null) and not (nvl(telsumm_tele_directory,'xxx') IN ('N','S','D')) and not (telsumm_tele_number IS NULL AND telsumm_alias IS NULL) and (telsumm_alias_list = 'Y' OR (telsumm_tele_directory IN ('A','B'))) and ((nvl(telsumm_system_id_end,sysdate+1) > SYSDATE and telsumm_entity_type = 'P') or (telsumm_entity_type = 'N')) and (telsumm_search_department NOT like 'SPONSOR%')"; if (search.getSurname().length() > 0) { SQL += " and (telsumm_search_surname like '" + search.getSurname().toUpperCase() + "%')"; } if (search.getSurnameLike().length() > 0) { SQL += " and (telsumm_search_soundex like soundex(('%" + search.getSurnameLike().toUpperCase() + "%'))"; } if (search.getFirstname().length() > 0) { SQL += " and (telsumm_search_preferred_name like '" + search.getFirstname().toUpperCase() + "%' or telsumm_search_first_name like '" + search.getFirstname() + "%')"; } if (search.getTelephoneNumber().length() > 0) { SQL += " and (telsumm_tele_number like '" + search.getTelephoneNumber() + "%')"; } if (search.getDepartment().length() > 0) { SQL += " and (telsumm_search_department like '" + search.getDepartment().toUpperCase() + "%')"; } if (search.getRole().length() > 0) { SQL += " and (telsumm_search_role like '" + search.getRole().toUpperCase() + "%')"; } SQL += " order by surname, firstname"; List<Object[]> list = (List<Object[]>) sessionFactory.getCurrentSession().createQuery(SQL).list(); for(int j=0;j<list.size();j++){ Object [] obj= (Object[])list.get(j); for(int i=0;i<obj.length;i++) System.out.println(obj[i]); }*/ System.out.println("test"); return "test"; } }

    Read the article

  • Compile classfile issue in Spring 3

    - by Prajith R
    I have used spring framework 3 for my application. Everything is ok while developed in Netbeans But i need a custom build and done for the same The build created without any issue, but i got the following error The error occurred while calling the following method @RequestMapping(value = "/security/login", method = RequestMethod.POST) public ModelAndView login(@RequestParam String userName, @RequestParam String password, HttpServletRequest request) { ...................... But There is no issue while creating the war with netbeans (I am sure it is about the compilation issue) have you any experiance on this issue ... There is any additional javac argument for compile the same (netbeans used there custom task for the compilation) type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.mypackage.security.controller.LoginController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:659) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.mypackage.security.controller.AuthFilter.doFilter(Unknown Source) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) root cause org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public org.springframework.web.servlet.ModelAndView com.mypackage.security.controller.LoginController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)]; nested exception is java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.mypackage.security.controller.AuthFilter.doFilter(Unknown Source) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) root cause java.lang.IllegalStateException: No parameter name specified for argument of type [java.lang.String], and no parameter name information found in class file either. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.getRequiredParameterName(HandlerMethodInvoker.java:618) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveRequestParam(HandlerMethodInvoker.java:417) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:277) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:163) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.mypackage.security.controller.AuthFilter.doFilter(Unknown Source) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.

    Read the article

  • "state is undetermined" when starting Grails app on CloudFoundry

    - by SeattleStephens
    I have a Grails app that has been running on CloudFoundry for months. I updated the app from Grails 2.0.4 to 2.1.0 and also updated a few plugins I have been using. Now when I push the app to CloudFoundry and do the start, I receive the error: 'appname' state is undetermined, not enough information available. The tomcat Catalina log shows the NoClassDefFoundError below. I've read about issues with the Ivy cache but have not looked into that yet. I have updated vmc to the latest version (0.3.18). SEVERE: Error deploying web application directory ROOT java.lang.NoClassDefFoundError: org/apache/tomcat/PeriodicEventListener at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1128) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.PeriodicEventListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) ... 34 more

    Read the article

  • Problem with Java Mail : No provider for smtp

    - by user359198
    Hello all. I am using JavaMail to do a simple application that sends an email when it finds some files in a directory. I managed to get it worked from Eclipse. I Run the application and it sent the email with no errors. But, when I created the jar, and executed it, it fails in the email sending part. It gives this exception. javax.mail.NoSuchProviderException: No provider for smtp at javax.mail.Session.getProvider(Session.java:460) at javax.mail.Session.getTransport(Session.java:655) at javax.mail.Session.getTransport(Session.java:636) at main.java.util.MailManager.sendMail(MailManager.java:69) at main.java.DownloadsMail.composeAndSendMail(DownloadsMail.java:16) at main.java.DownloadsController.checkDownloads(DownloadsController.java:51) at main.java.MainDownloadsController.run(MainDownloadsController.java:26) at java.lang.Thread.run(Unknown Source) I am using the library in this method: public static boolean sendMail(String subject, String text){ noExceptionsThrown = true; try { loadProperties(); } catch (IOException e1) { System.out.println("Problem encountered while loading properties"); e1.printStackTrace(); noExceptionsThrown = false; } Properties mailProps = new Properties(); String host = "mail.smtp.host"; mailProps.setProperty(host, connectionProps.getProperty(host)); String tls = "mail.smtp.starttls.enable"; mailProps.setProperty(tls, connectionProps.getProperty(tls)); String port = "mail.smtp.port"; mailProps.setProperty(port, connectionProps.getProperty(port)); String user = "mail.smtp.user"; mailProps.setProperty(user, connectionProps.getProperty(user)); String auth = "mail.smtp.auth"; mailProps.setProperty(auth, connectionProps.getProperty(auth)); Session session = Session.getDefaultInstance(mailProps); //session.setDebug(true); MimeMessage message = new MimeMessage(session); try { message.setFrom(new InternetAddress(messageProps.getProperty("from"))); message.addRecipient(Message.RecipientType.TO, new InternetAddress( messageProps.getProperty("to"))); message.setSubject(subject); message.setText(text); Transport t = session.getTransport("smtp"); try { t.connect(connectionProps.getProperty("user"), passwordProps .getProperty("password")); t.sendMessage(message, message.getAllRecipients()); } catch (Exception e) { System.out.println("Error encountered while sending the email"); e.printStackTrace(); noExceptionsThrown = false; } finally { t.close(); } } catch (Exception e) { System.out.println("Error encountered while creating the message"); e.printStackTrace(); noExceptionsThrown = false; } return noExceptionsThrown; } I am loading these values from properties files. mail.smtp.host=smtp.gmail.com mail.smtp.starttls.enable=true mail.smtp.port=587 mail.smtp.auth=true I have tried to change the host by ssl://smtp.gmail.com, the port by 465 (just for trying something different), but it doesn't work either. Anyway, if it works fine from Eclipse with the original parameters, I guess that the values are correct, but the problem is creating the jar. I don't know very much about the possible results or changes when creating a jar. Could the JavaMail libraries someway go wrong when the jar is created? Do you have any ideas? Thank you very much for your help.

    Read the article

  • Making a app show inside a GUI in Java

    - by José
    Hello. I have one problem I've been dealing with for this week. You see, I'm new to Java, so that's probably it... Anyways, I've started a project out of pure curiosity. I had it done in Java, but in plain CMD-style, which is not very pretty. It calls one of my ten programs, chosen by the user using "Case". Eg.: If you type 1, it will go to program 1. After you finish it, it goes back to selection until the user press 0. After that, I've been trying to make a GUI for it. I've been able to create the selector alone and make it respond to the numbers chosen. If you press 1 and click ok, it will tell you you've chosen program 1. I, however, have not been able to make it run the program. I've been trying to make the program show up in a jPanel, part of the main GUI. I failed miserably. The program runs in separate but I can't make them run together like the CMD one. The apps were made in Eclipse SDK 3.5.2 The GUIs were made in Netbeans IDE 6.8 Here's the code for the GUI only (the prints are in PT-BR, my native language): Main program: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * ProgramasGUI.java * * Created on 31/01/2010, 22:56:19 */ package Main; import Main.Prog1; /** * * @author Zeh® */ public class ProgramasGUI extends javax.swing.JFrame { /** Creates new form ProgramasGUI */ public ProgramasGUI() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { selecao = new javax.swing.JTextField(); mostrador = new javax.swing.JLabel(); selecionar = new javax.swing.JButton(); mostrador1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); selecao.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { selecaoActionPerformed(evt); } }); mostrador.setText("Qual o programa desejado?"); selecionar.setText("OK"); selecionar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { selecionarActionPerformed(evt); } }); mostrador1.setText("Saiba aqui o Programa escolhido!"); jPanel1.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentShown(java.awt.event.ComponentEvent evt) { jPanel1ComponentShown(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(selecao, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(selecionar, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(mostrador1, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(mostrador, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(162, 162, 162) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(39, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(selecao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(mostrador, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(selecionar) .addComponent(mostrador1)) .addContainerGap()) ); pack(); }// </editor-fold> private void selecaoActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void selecionarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int programa = (int)((Double.parseDouble(selecao.getText()))); switch (programa) { case 1: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 2: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 3: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 4: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 5: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 6: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 7: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 8: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 9: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break; case 10: mostrador1.setText("O programa " + programa + " foi escolhido!" ); break;} } private void jPanel1ComponentShown(java.awt.event.ComponentEvent evt) { int programa = (int)((Double.parseDouble(selecao.getText()))); switch (programa) { case 1: addNotify(Prog1.); break;} } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ProgramasGUI().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JPanel jPanel1; private javax.swing.JLabel mostrador; private javax.swing.JLabel mostrador1; private javax.swing.JTextField selecao; private javax.swing.JButton selecionar; // End of variables declaration } And here's the sub-program: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Prog1.java * * Created on 02/02/2010, 23:57:59 */ package Main; /** * * @author Zeh® */ public class Prog1 extends javax.swing.JPanel { /** Creates new form Prog1 */ public Prog1() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); numesc = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); campo = new javax.swing.JTextField(); jLabel1.setText("Saiba aqui o Antecessor!"); numesc.setText("O número escolhido é: X"); jLabel3.setText("Saiba aqui o Sucessor!"); jLabel4.setText("Insira um número para saber seu Antecessor e Sucessor!"); jButton1.setText("Calcular!"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); campo.setText("Insira seu número"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jButton1)) .addComponent(campo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jLabel3)) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(numesc, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))) .addComponent(jLabel4)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel4) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(campo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(numesc) .addGap(11, 11, 11) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jButton1)) .addContainerGap(24, Short.MAX_VALUE)) ); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int num = (int)((Double.parseDouble(campo.getText()))); numesc.setText("O número escolhido é: " + num); int x = num-1; jLabel1.setText ("O antecessor é: " + x); int y = num+1; jLabel3.setText ("O sucessor é: " + y); } // Variables declaration - do not modify private javax.swing.JTextField campo; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel numesc; // End of variables declaration } Any help would be very appreciated. If I, for some reason, made a mistake typing and/or setting the layout of this post incorrectly, please accept my apologies.

    Read the article

  • tried to update hudson via dashboard and now it doesn;t work (windows)

    - by Tim
    I get the following now in the output log. I really wish I hadn't attempted to update teh version. What a hassle. Can anyone diagnose the issue here? Running from: C:\hudson\hudson.war [Winstone 2010/06/14 23:33:54] - Beginning extraction from war file hudson home directory: C:\hudson [Winstone 2010/06/14 23:33:56] - Error during HTTP listener init or shutdown java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(Unknown Source) at java.net.ServerSocket.bind(Unknown Source) at java.net.ServerSocket.(Unknown Source) at java.net.ServerSocket.(Unknown Source) at winstone.HttpListener.getServerSocket(HttpListener.java:102) at winstone.HttpListener.run(HttpListener.java:116) at java.lang.Thread.run(Unknown Source) [Winstone 2010/06/14 23:33:56] - HTTP Listener shutdown successfully [Winstone 2010/06/14 23:33:56] - Winstone Servlet Engine v0.9.10 running: controlPort=disabled [Winstone 2010/06/14 23:33:56] - Error during AJP13 listener init or shutdown java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(Unknown Source) at java.net.ServerSocket.bind(Unknown Source) at java.net.ServerSocket.(Unknown Source) at java.net.ServerSocket.(Unknown Source) at winstone.ajp13.Ajp13Listener.run(Ajp13Listener.java:99) at java.lang.Thread.run(Unknown Source) [Winstone 2010/06/14 23:33:56] - AJP13 Listener shutdown successfully Running from: C:\hudson\hudson.war [Winstone 2010/06/14 23:38:49] - Beginning extraction from war file hudson home directory: C:\hudson [Winstone 2010/06/14 23:38:51] - Winstone Servlet Engine v0.9.10 running: controlPort=disabled [Winstone 2010/06/14 23:38:51] - Error during AJP13 listener init or shutdown java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(Unknown Source) at java.net.ServerSocket.bind(Unknown Source) at java.net.ServerSocket.(Unknown Source) at java.net.ServerSocket.(Unknown Source) at winstone.ajp13.Ajp13Listener.run(Ajp13Listener.java:99) at java.lang.Thread.run(Unknown Source) [Winstone 2010/06/14 23:38:51] - AJP13 Listener shutdown successfully [Winstone 2010/06/14 23:38:51] - Error during HTTP listener init or shutdown java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(Unknown Source) at java.net.ServerSocket.bind(Unknown Source) at java.net.ServerSocket.(Unknown Source) at java.net.ServerSocket.(Unknown Source) at winstone.HttpListener.getServerSocket(HttpListener.java:102) at winstone.HttpListener.run(HttpListener.java:116) at java.lang.Thread.run(Unknown Source) [Winstone 2010/06/14 23:38:51] - HTTP Listener shutdown successfully

    Read the article

  • How to use Java on Google App Engine without exceeding minute quotas?

    - by Geo
    A very simple java code inside a doGet() servlet is getting more than a second of cpu time on GAE. I have read some quota related documentation and apparently I am not doing anything wrong. //Request the user Agent info String userAgent = req.getHeader("User-Agent"); I wanted to know what was using the CPU the most, I use a google help recommendation. //The two lines below will get the CPU before requesting User-Agent Information QuotaService qs = QuotaServiceFactory.getQuotaService(); long start = qs.getCpuTimeInMegaCycles(); //Request the user Agent info String userAgent = req.getHeader("User-Agent"); //The three lines below will get the CPU after requesting User-Agent Information // and informed it to the application log. long end = qs.getCpuTimeInMegaCycles(); double cpuSeconds = qs.convertMegacyclesToCpuSeconds(end - start); log.warning("CPU Seconds on geting User Agent: " + cpuSeconds); The only thing that the code above tells me is that inspecting the header will use more than a second (1000ms) of cpu time, which for Google is a warning on the log panel. That seems to be a very simple request and still is using more than a second of cpu. What I am missing?

    Read the article

  • java label setText and setBounds clashing?

    - by java
    I would like to have a JLabel changint color to a random one, while jumping to a random position, and while changing its text. but the setText and setBounds seem to clash and i don't know why. if you comment out the setText then the setBounds will work, but they won't work together. import java.awt.*; import java.util.*; import javax.swing.*; public class test2 extends JFrame { private static JLabel label = new JLabel("0"); private static Random gen = new Random(); public test2() { JPanel panel = new JPanel(); panel.add(label); this.add(panel); } public static void move() { for (int i = 0; i < 10; i++) { int n = gen.nextInt(254)+1; int nn = gen.nextInt(254)+1; int nnn = gen.nextInt(254)+1; label.setText(""+i); //the setBounds command will not work with the setText command. why? label.setBounds(n*2, nn*2, 20, 20); label.setForeground(new Color(n, nn, nnn)); try { Thread.sleep(200); } catch (Exception e) {} } } public static void main(String[] args) { test2 frame = new test2(); frame.setVisible(true); frame.setSize(600, 600); frame.setResizable(true); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); move(); } }

    Read the article

  • Is method reference caching a good idea in Java 8?

    - by gexicide
    Consider I have code like the following: class Foo { Y func(X x) {...} void doSomethingWithAFunc(Function<X,Y> f){...} void hotFunction(){ doSomethingWithAFunc(this::func); } } Consider that hotFunction is called very often. Would it then be advisable to cache this::func, maybe like this: class Foo { Function<X,Y> f = this::func; ... void hotFunction(){ doSomethingWithAFunc(f); } } As far as my understanding of java method references goes, the Virtual Machine creates an object of an anonymous class when a method reference is used. Thus, caching the reference would create that object only once while the first approach creates it on each function call. Is this correct? Should method references that appear at hot positions in the code be cached or is the VM able to optimize this and make the caching superfluous? Is there a general best practice about this or is this highly VM-implemenation specific whether such caching is of any use?

    Read the article

  • java AbstractMethodError

    - by Akhil
    How to handle this error in lucene: java.lang.AbstractMethodError: org.apache.lucene.store.Directory.listAll()[Ljava/lang/String; at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:568) at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:69) at org.apache.lucene.index.IndexReader.open(IndexReader.java:316) at org.apache.lucene.index.IndexReader.open(IndexReader.java:188) I am making a lucene function call but unfortunately it itself calls an abstract method of some class, as is evident from the error above. What is the work around for this? Thanks, --Akhil

    Read the article

  • Java applets vs Silverlight vs Flash (Flex)

    - by Peter Gfader
    Everybody talks about Silverlight and Flash and Flex and how cool etc... Java applets are very similar to Silverlight and Flex, but Java applets exist since 1995. What is the reason we don't have any cool Java applet applications around? My guesses so far: start up time of Java applet, restricted network connectivity, lack of dev tools, ... Are there any cool Java applets around? Please post links

    Read the article

  • Connecting to MSSQL 2008 from Java

    - by Xinus
    I am trying to connect to MSSQL 2008 server from Java here is a program import java.sql.*; public class connectURL { public static void main(String[] args) { // Create a variable for the connection string. String connectionUrl = "jdbc:sqlserver://localhost/SQLEXPRESS/Databases/HelloWorld:1433;";// + //"databaseName=HelloWorld;integratedSecurity=true;"; // Declare the JDBC objects. Connection con = null; Statement stmt = null; ResultSet rs = null; try { // Establish the connection. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con = DriverManager.getConnection(connectionUrl); // Create and execute an SQL statement that returns some data. String SQL = "SELECT TOP 10 * FROM Person.Contact"; stmt = con.createStatement(); rs = stmt.executeQuery(SQL); // Iterate through the data in the result set and display it. while (rs.next()) { System.out.println(rs.getString(4) + " " + rs.getString(6)); } } // Handle any errors that may have occurred. catch (Exception e) { e.printStackTrace(); } finally { if (rs != null) try { rs.close(); } catch(Exception e) {} if (stmt != null) try { stmt.close(); } catch(Exception e) {} if (con != null) try { con.close(); } catch(Exception e) {} } } } But it shows error as com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost/SQLEXPRESS/Databases/HelloWorld, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.". at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1049) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at connectURL.main(connectURL.java:43) I have given followed all the instructions as given in http://teamtutorials.com/database-tutorials/configuring-and-creating-a-database-in-ms-sql-2008 What can be the problem ?

    Read the article

  • Problem with import java.nio.file

    - by Richard Knop
    Why this line doesn't work? import static java.nio.file.AccessMode.*; Eclipse says: The import java.nio.file cannot be resolved Here is the whole program so far: import static java.nio.file.AccessMode.*; public class CheckFileAccessibility { public static void main(String[] args) { } } I am following the official Java tutorial here: http://java.sun.com/docs/books/tutorial/essential/io/check.html

    Read the article

  • Is deep Java knowledge needed for Android?

    - by MigNix
    Hi, I am C++ developer interested in Android. As I understand the only possibility to develop applications for Android is Java. There is NDK also, but as I can see it is just something like JNI for Java. Is it mandatory to learn Java or to have deep knowledge in Java then try Android SDK, or it would be possible to learn Java while developing for Android. Thank you.

    Read the article

  • crude Runtime.exec to call java -cp not working in linux

    - by pstanton
    I'm using a java process to spawn many other java processes using Runtime.exec(cmd) where cmd is like the following: java -cp "MyJar.jar" pkg.MyClass some-more-arguments running the same command from the command line works fine in windows and linux, however when my spawning java process calls the command via Runtime.exec it works in windows but not in linux. in linux i get Exception in thread "main" java.lang.NoClassDefFoundError: pkg/MyClass any ideas?

    Read the article

  • Java: using foreach over strings from arrayList does not print anything

    - by HH
    $ javac ArrayListTest.java $ java ArrayListTest $ cat ArrayListTest.java import java.io.*; import java.util.*; public class ArrayListTest{ public static void main(String[] args) { try { String hello ="oeoaseu oeu hsoae sthoaust hoaeut hoasntu"; ArrayList<String> appendMe = null; for(String s : hello.split(" ")) appendMe.add(s+" "); for(String s : appendMe) System.out.println(s); //WHY DOES IT NOT PRINT? }catch(Exception e){ } } }

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >