Search Results

Search found 1161 results on 47 pages for 'roman kagan'.

Page 18/47 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Can I close and reopen a socket?

    - by Roman
    I learned an example of usage of sockets. In this example a client sends a request to a server to open a socket and then the server (listening to a specific port) opens a socket and everything is fine, socket is "opened" from both sides (client and server). But it is still not clear to me how flexible is this stuff. For example, is it possible for the client to close an opened (from both ends) socket and to reopen it again (under condition that the server keeps the socket opened). Is it possible for the server to "know" that a socket was closed on the client side? Is it possible for the client to know that a socket was closed on the server side?

    Read the article

  • How can I find a package?

    - by Roman
    In my code I have the following statement import com.apple.dnssd.*; and compiler (javac) complains about this line. It writes that the package does not exist. But I think that it could be that "javac" search the package in a wrong place (directory). In this respect I have two questions: How can I know where javac search for the packages? I think that it is very likely that I have the above mentioned package but I do not know where it is located. What are the typical place to look for the packages?

    Read the article

  • Hibernate error: cannot resolve table

    - by Roman
    I'm trying to make work the example from hibernate reference. I've got simple table Pupil with id, name and age fields. I've created correct (as I think) java-class for it according to all java-beans rules. I've created configuration file - hibernate.cfg.xml, just like in the example from reference. I've created hibernate mapping for one class Pupil, and here is the error occured. <hibernate-mapping> <class name="Pupil" table="pupils"> ... </class> </hibernate-mapping> table="pupils" is red in my IDE and I see message "cannot resolve table pupils". I've also founded very strange note in reference which says that most users fail with the same problem trying to run the example. Ah.. I'm very angry with this example.. IMHO if authors know that there is such problem they should add some information about it. But, how should I fix it? I don't want to deal with Ant here and with other instruments used in example. I'm using MySql 5.0, but I think it doesn't matter. UPD: source code Pupil.java - my persistent class package domain; public class Pupil { private Integer id; private String name; private Integer age; protected Pupil () { } public Pupil (String name, int age) { this.age = age; this.name = name; } public Integer getId () { return id; } public void setId (Integer id) { this.id = id; } public String getName () { return name; } public void setName (String name) { this.name = name; } public Integer getAge () { return age; } public void setAge (Integer age) { this.age = age; } public String toString () { return "Pupil [ name = " + name + ", age = " + age + " ]"; } } Pupil.hbm.xml is mapping for this class <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="domain" > <class name="Pupil" table="pupils"> <id name="id"> <generator class="native" /> </id> <property name="name" not-null="true"/> <property name="age"/> </class> </hibernate-mapping> hibernate.cfg.xml - configuration for hibernate <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost/hbm_test</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <property name="connection.pool_size">1</property> <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="current_session_context_class">thread</property> <property name="show_sql">true</property> <mapping resource="domain/Pupil.hbm.xml"/> </session-factory> </hibernate-configuration> HibernateUtils.java package utils; import org.hibernate.SessionFactory; import org.hibernate.HibernateException; import org.hibernate.cfg.Configuration; public class HibernateUtils { private static final SessionFactory sessionFactory; static { try { sessionFactory = new Configuration ().configure ().buildSessionFactory (); } catch (HibernateException he) { System.err.println (he); throw new ExceptionInInitializerError (he); } } public static SessionFactory getSessionFactory () { return sessionFactory; } } Runner.java - class for testing hibernate import org.hibernate.Session; import java.util.*; import utils.HibernateUtils; import domain.Pupil; public class Runner { public static void main (String[] args) { Session s = HibernateUtils.getSessionFactory ().getCurrentSession (); s.beginTransaction (); List pups = s.createQuery ("from Pupil").list (); for (Object obj : pups) { System.out.println (obj); } s.getTransaction ().commit (); HibernateUtils.getSessionFactory ().close (); } } My libs: antlr-2.7.6.jar, asm.jar, asm-attrs.jar, cglib-2.1.3.jar, commons-collections-2.1.1.jar, commons-logging-1.0.4.jar, dom4j-1.6.1.jar, hibernate3.jar, jta.jar, log4j-1.2.11.jar, mysql-connector-java-5.1.7-bin.jar Compile error: cannot resolve table pupils

    Read the article

  • How do the size standard libraries compare for different languages

    - by Roman A. Taycher
    Someone was recently raving about how great jQuery was and how it made javascript into a pleasure and also how the whole source code was so small(and one file). I looked it up on www.ohloh.net/ and it said it was about 30,000 lines of javascript, when I tired curl piped to wc it said about 5000 lines(strange discrepancy that, maybe test suites, ect?). I thought well it isn't that strange since javascript from what I've heard has a lot of fun dynamic tricks, so you can probably get away with a small library. But then I thought what about other high level languages, the ones with large standard libraries and wondered how big the standard are for python/ruby/haskell/pharo(smalltalk)/*ml/ect. (libraries not vm stuff to the degree its possible to separate it) Anybody know? Any details (comment/blank/code lines , test code lines, lines in language vs lines in ffi/byte-code) are appreciated! edit: ps. since it started this me asking about jQuery as a bonus if you could please list the size of mega frameworks, a megaframewok provides so much that people using an x megaframework in language y might sometimes refer to programming in xy or even x rather then in y (ie. : qt, jQuery, etc.).

    Read the article

  • How the simples GUI countdown is supposed to work?

    - by Roman
    I am trying to write the simples GUI countdown. I found in Internet some code but it is already too fancy for me. I am trying to keep it as simple as possible. So, I just want to have a window saying "You have 10 second left". The number of second should decrease every second from 10 to 0. I wrote a code. And I think I am close to the working solution. But I still missing something. Could you pleas help me to find out what is wrong? Here is my code: import javax.swing.*; public class Countdown { static JLabel label; // Method which defines the appearance of the window. private static void showGUI() { JFrame frame = new JFrame("Simple Countdown"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Some Text"); frame.add(label); frame.pack(); frame.setVisible(true); } // Define a new thread in which the countdown is counting down. static Thread counter = new Thread() { public void run() { for (int i=10; i>0; i=i-1) { updateGUI(i,label); try {Thread.sleep(1000);} catch(InterruptedException e) {}; } } }; // A method which updates GUI (sets a new value of JLabel). private static void updateGUI(final int i, final JLabel label) { SwingUtilities.invokeLater(new Runnable(i,label) { public Runnable(int i, JLabel label) { this.i = i; this.label = label; } public void run() { label.setText("You have " + i + " seconds."); } }); } // The main method (entry point). public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { showGUI(); //counter.start(); } }); //counter.start(); } } And I have several concrete question about this code: Where should I place the counter.start();? (In my code I put it on 2 places. Which one is correct?) Why compiler complains about the constructor for Runnable? It says that I have an invalid method declaration and I need to specify the returned type. ADDED: I made the suggested corrections. And then I execute the code and get: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at Worker.run(Worker.java:12) In the Worker.java in the line 12 I have: label.setText("You have " + i + " seconds.");.

    Read the article

  • Placement new in gcc

    - by Roman Prikhodchenko
    I need to find a workaround for a bug with placement new in g++. I now it was fixed in gcc-4.3 but I have to support versions 4.2 and 4.1. For example, following code compiles with an error "error: no matching function for call to 'operator new(long unsigned int, void*&)" template<class T, template<typename> class Alloc> inline void* type_ctor() { Alloc<T> a; void* p = a.allocate(1); new(p) T; return p; } ..... type_ctor<A, NewAllocator >();

    Read the article

  • Why a EDT violation happens?

    - by Roman
    I started to use CheckThreadViolationRepaintManager to detect EDT violations. It complains about: partner = getParameter("partner",generatePartnerSelectionPanel(),Design.partnerSelectionDuration); Because it does not like generatePartnerSelectionPanel() because it does not like JPanel panel = new JPanel(); in this method. But I cannot find out why there should be a problem around that. In more details, generatePartnerSelectionPanel() generates a JPanel (I do it not in the EDT) but then, in the getParameter I add the JPanel to the main JFrame and I do it in the EDT (using invokeLater). So, why there should be a problem?

    Read the article

  • Invoke Maven-Module build from intellij

    - by Roman
    Hi All I was wondering if someone knows a way to invoke a specific maven module build from IntelliJ that will also build ( or use already compiled classes ) from depended modules. So for instance if I would like to build the module "Model" in the picture and only it , it seems reasonable for me to click the package step on it. But what is actually does it invokes the mvn package step inside this specific module rather than "mvn -am -pl module-name" from the root module , which also builds all the dependencies. So is there something that I just don't know ?

    Read the article

  • Rank Source Control Options-VSS vs CVS vs none vs your own hell

    - by Roman A. Taycher
    It seems like a lot of people here and on many programmer wikis/blogs/ect. elsewhere really dislike VSS. A lot of people also have a serious dislike for cvs. In many places I have heard a lot of differing opinions on whether or not using VSS or cvs is better or worse then using no source control, please rate the worst and explain why!!!!! you rated them this way. Feel free to throw in your own horrible system in the rankings. If you feel it depends on the circumstances try to explain the some of the different scenarios which lead to different rankings. (note:I see a lot of discussion of what is better but little of what is worse.) second note: while both answers are nice I'm looking less for good replacements and more for a comparison of which is worse and more importantly why!

    Read the article

  • RedirectStandardInput crashes program

    - by Roman
    Hi, the following code is to open a console application (which uses pdcurses for output, nothing special): myProcess.StartInfo.FileName = "some.exe"; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.CreateNoWindow = false; myProcess.StartInfo.RedirectStandardInput = true; myProcess.Start(); The Problem is that it opens the designated window but directly closes it (it's barely visible). Starting the program without RedirectStandardInput works. The problem is that it does not throw an exception nor any error-message. What is wrong with my code? How can I write input to the program? Thanks.

    Read the article

  • How can I shift html-text in the JButton to the left?

    - by Roman
    I use HTML to put text into a JButton. In this way I can play with colors and text size. What I do not like is the distance from the left border of the button and the text (this separation is too large). Is there a way to decrease this distance? I think it should be some parameter in the style of the HTML code. Sample of the code: JButton btn = new JButton("<html><span style='color:#000000; font-size: 11pt;'>" + label + "</span></html>");

    Read the article

  • How can I easily run different configurations in Eclipse?

    - by Roman
    I have an Java applications which I would like to run with different values of input parameters (specified in the command line). In "Run - Run Configurations" I have created different configurations corresponding to different values of the input arguments. I can run these configurations in the same way (throw "Run - Run Configurations"). But in these case I have to perform to many actions (clicks) to run a particular configuration. Is there a easier (faster) way to do that? For example I expect that I can do it throw "Run - Run as" but in the drop-dawn menu of the "Run as" I see "(Not Applicable)".

    Read the article

  • Build specific module in multi-module project

    - by Roman
    Hi I have a multi-module project. I thought I can compile only a single module from that multi module project by that line : mvn -amd -pl "module-name" Seems not to work , this command builds only the specific module. Its dependencies are not compiled yet so it fails. Any ideas how to solve that ? Thanks

    Read the article

  • How to handle large dataset with JPA (or at least with Hibernate)?

    - by Roman
    I need to make my web-app work with really huge datasets. At the moment I get either OutOfMemoryException or output which is being generated 1-2 minutes. Let's put it simple and suppose that we have 2 tables in DB: Worker and WorkLog with about 1000 rows in the first one and 10 000 000 rows in the second one. Latter table has several fields including 'workerId' and 'hoursWorked' fields among others. What we need is: count total hours worked by each user; list of work periods for each user. The most straightforward approach (IMO) for each task in plain SQL is: 1) select Worker.name, sum(hoursWorked) from Worker, WorkLog where Worker.id = WorkLog.workerId group by Worker.name; //results of this query should be transformed to Multimap<Worker, Long> 2) select Worker.name, WorkLog.start, WorkLog.hoursWorked from Worker, WorkLog where Worker.id = WorkLog.workerId; //results of this query should be transformed to Multimap<Worker, Period> //if it was JDBC then it would be vitally //to set resultSet.setFetchSize (someSmallNumber), ~100 So, I have two questions: how to implement each of my approaches with JPA (or at least with Hibernate); how would you handle this problem (with JPA or Hibernate of course)?

    Read the article

  • Why my inner class DO see a NON static variable?

    - by Roman
    Earlier I had a problem when an inner anonymous class did not see a field of the "outer" class. I needed to make a final variable to make it visible to the inner class. Now I have an opposite situation. In the "outer" class "ClientListener" I use an inner class "Thread" and the "Thread" class I have the "run" method and does see the "earPort" from the "outer" class! Why? import java.io.IOException; import java.net.*; import java.io.BufferedReader; import java.io.InputStreamReader; public class ClientsListener { private int earPort; // Constructor. public ClientsListener(int earPort) { this.earPort = earPort; } public void starListening() { Thread inputStreamsGenerator = new Thread() { public void run() { System.out.println(earPort); try { System.out.println(earPort); ServerSocket listeningSocket = new ServerSocket(earPort); Socket serverSideSocket = listeningSocket.accept(); BufferedReader in = new BufferedReader(new InputStreamReader(serverSideSocket.getInputStream())); } catch (IOException e) { System.out.println(""); } } }; inputStreamsGenerator.start(); } }

    Read the article

  • Why SetMinimumSize sets the minimal heights but not width?

    - by Roman
    Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { public static void main(String[] args) { JFrame frame = new JFrame("Colored Trails"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); JPanel firstPanel = new JPanel(); firstPanel.setLayout(new GridLayout(4, 4)); firstPanel.setMaximumSize(new Dimension(4*100, 4*100)); firstPanel.setMinimumSize(new Dimension(4*100, 4*100)); JButton btn; for (int i=1; i<=4; i++) { for (int j=1; j<=4; j++) { btn = new JButton(); btn.setPreferredSize(new Dimension(100, 100)); firstPanel.add(btn); } } mainPanel.add(firstPanel); frame.add(mainPanel); frame.setSize(520,600); //frame.setMinimumSize(new Dimension(520,600)); frame.setVisible(true); } } When I increase the size of the window (by mouse) I see that my panel does not increase its size. It is the expected behavior (because I set the maximal size of the panel). However, when I decrease the size of the window, I see that width of the panel is decreased too (while the height is constant). So, the setMinimumSize works only partially. Why is that?

    Read the article

  • What is the relation between ContentPane and JPanel?

    - by Roman
    I found one example in which buttons are added to panels (instances of JPanel) then panels are added to the the containers (instances generated by getContentPane) and then containers are, by the construction, included into the JFrame (the windows). I tried two things: I got rid of the containers. In more details, I added buttons to a panel (instance of JPanel) and then I added the panel to the windows (instance of JFrame). It worked fine. I got rid of the panels. In more details, I added buttons directly to the container and then I added the container to the window (instance of JFrame). So, I do not understand two things. Why do we have two competing mechanism to do the same things. What is the reason to use containers in combination with the panels (JPanel)? (For example, what for we include buttons in JPanels and then we include JPanels in the Containers). Can we include JPanel in JPanel? Can we include a container in container?

    Read the article

  • How a thread should close itself in Java?

    - by Roman
    This is a short question. At some point my thread understand that it should suicide. What is the best way to do it: Thread.currentThread().interrupt(); return; By the way, why in the first case we need to use currentThread? Is Thread does not refer to the current thread?

    Read the article

  • Using ClrProfiler

    - by Roman Dorevich
    Hello, I am trying to use CLRProfiler. I need to enter some parameters, so I used the the File-set parameters option and added both parameters and the working directory. When the application starts it takes some parameters from a inifile but the clr fails to find parameters from the inifile cause it concrat it with the working directory. thanks

    Read the article

  • What is "src" directory created by Eclipse?

    - by Roman
    I just installed Eclipse. The Eclipse created the "workspace" folder. In this folder I created a "game" sub-folder (for my class called "game"). I have already .java files for that project (I wrote them in a text editor before I started to use Eclipse). I put all my .java file into the "game" directory. In Eclipse I created a "New Java Project" from existing code. What wanders me is that the Eclipse create a "src" sub-folder into my "game" folder. As far as I understand "src" stands for "source". But my source (.java files) is in the "game" (by the construction). Am I doing something wrong?

    Read the article

  • How to add an element to an array without a modification of the old array or creation a new one?

    - by Roman
    I have the following construction: for (String playerName: players). I would like to make a loop over all players plus one more special player. But I do not want to modify the players array by adding a new element to it. So, what can I do? Can I replace players in the for (String playerName: players) by something containing all elements of the players plus one more element?

    Read the article

  • Huge amount of time sending data with suds and proxy

    - by Roman
    Hi everyone, I have the following code to send data through a proxy using suds: import suds t = suds.transport.http.HttpTransport() proxy = urllib2.ProxyHandler({'http': 'http://192.168.3.217:3128'}) opener = urllib2.build_opener(proxy) t.urlopener = opener ws = suds.client.Client('http://xxxxxxx/web.asmx?WSDL', transport=t) req = ws.factory.create('ActionRequest.request') req.SerialNumber = 'asdf' req.HostName = 'hola' res = ws.service.ActionRequest(req) I don't know why, but it can be sending data above 2 or 3 minutes, or even more and it raises a "Gateway timeout" exception sometimes. If I don't use the proxy, the amount of time used is above 2 seconds or less. Here is the SOAP reply: (ActionResponse){ Id = None Action = "Action.None" Objects = "" } The proxy is running right with other requests through urllib2, or using normal web browsers like firefox. Does anyone have any idea what's happening here with suds? Thanks a lot in advance!!!

    Read the article

  • Are there any reasons to make all fields and variables final?

    - by Roman
    In my current project I noticed that all class fields and variable inside methods are declared with final modifier whenever it's possible. Just like here: private final XMLStreamWriter _xmlStreamWriter; private final Marshaller _marshaller; private final OutputStream _documentStream; private final OutputStream _stylesStream; private final XMLStreamWriter _stylesStreamWriter; private final StyleMerger _styleMerger; public DocumentWriter(PhysicalPackage physicalPackage) throws IOException { final Package pkg = new Package(physicalPackage); final Part wordDocumentPart = pkg.createPart( "/word/document.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"); // styles.xml final Pair<Part, String> wordStylesPart = wordDocumentPart.createRelatedPart(...); ... } Are there any reasons to do so? p.s. As I know project is not supposed to be multithreaded (at least I've heard nothing about it).

    Read the article

  • Samples of Scala and Java code where Scala code looks simpler/has fewer lines?

    - by Roman
    I need some code samples (and I also really curious about them) of Scala and Java code which show that Scala code is more simple and concise then code written in Java (of course both samples should solve the same problem). If there is only Scala sample with comment like "this is abstract factory in Scala, in Java it will look much more cumbersome" then this is also acceptable. Thanks!

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >