w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
how to make application with time limit before it automatically closed in C
If you are on a POSIX system then use alarm(3) (credit to @Duck for suggesting this first in his comment): #include <stdio.h> #include <signal.h> #include <unistd.h> static void sighandler(int sig) { if (sig == SIGALRM) exit(0); } int main(int argc, const char **argv) { signal(SIGALRM, sighandler); alarm(15); // do things here }

Categories : C

I want to encrypt my symfony 2 application and make closed source
Does the entity work properly before encoding your project with Zend Guard? Is the following at the top of your entity class? <?php namespace SevenDaysTradeGestionDeStockBundleEntity; use DoctrineORMMapping as ORM; Note that you can't just use DoctrineORMMapping because the annotation is @ORMTable.

Categories : Symfony2

How to make a timer continuously running until closed by user?
Please have a look at the timers method: Timer.scheduleAtFixedRate(yourtimertask, yourdelay, yourinterval); Ths method will execute the code inside your TimerTask everytime the interval time passes. Here is a simple example of a Timer inside an Activity: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.yourlayout); MyTimerTask yourTask = new MyTimerTask(); Timer t = new Timer(); t.scheduleAtFixedRate(yourTask, 0, 10000); // 10 sec interval } class MyTimerTask extends TimerTask { public void run() { // do whatever you want in here } } I created my own TimerTask where I can do stuff inside its run method. In the onCreate() method, I start the timer and execute

Categories : Android

jQuery UI Tabs - Default Closed? How to make Collapsed on page load?
This could use some polish, but it should get you on the right track. http://jsfiddle.net/vbmMJ/2/ <html> <head> <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript"> $(function() { $("#tabs").tabs(); $(".tab-content").hide(); $(".ui-tabs-active").removeClass("ui-tabs-active"); $(".ui-state-active").removeClass("ui-state-active"); $(".ui-tabs-anchor").click(function() { $($(this).attr("href") + " .tab-content").first().show(); }); }); </script> </head>

Categories : Jquery

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

UnsupportedOperationException in Java when checking whether the resultSet is Closed or not
Apparently, the driver does not implement the method and throws java.lang.UnsupportedOperationException. Depending on the vendor (Oracle, IBM, Derby, ...), it can implement certain functionality of JDBC. You could only close the connection. This frees all resources.

Categories : Java

Is java frame completely disposed after being closed?
EXIT_ON_CLOSE will exit the application. You will have to manually clear the JFrame and (any invoked threads made by the user). using the frame.dispose(); Attach a window closed listener to the JFrame When triggered use the dispose method followed clearing swing elements and (killing threads that the user invokes). This will keep all the other windows open.

Categories : Java

Why am I getting java.sql.SQLException: Operation not allowed after ResultSet closed
All execution methods in the Statement interface implicitly close a statment's current ResultSet. See docs So you need to store resultSet data in a temporary array and loop through it. Or try to use another statement for executeUpdate. Try something like this: ArrayList<String> tmp = new ArrayList<String>(); while(resultsRS.next()){ tmp.add(resultsRS.getString(1)); } for (String s: tmp) { statement.executeUpdate("UPDATE suppliers SET status = status + 5 WHERE snum = "+"""+s+"""); rowCount++; }

Categories : Misc

java.io.IOException: Attempted read from closed stream
What does EntityUtils.toString(postResponse.getEntity()) do with the response entity? I would suspect, that it is consuming the entity's content stream. The HttpClient javadoc states, that only entities, which are repeatable can be consumed more than once. Therefore if the entity is not repeatable you cannot feed the content stream to the mapper again. To avoid this you should only let the mapper consume the stream - if logging of content is required, log the parsed Response object.

Categories : Java

How do I detect when a serial port has been closed by the device in java?
I have the same problem: I was trying to know when the device was unplugged from the USB port. Then, I found out that every time I unplugged the device from the USB port, it gets a java.io.IOException from the serialEvent. Take a look at my serialEvent code below: @Override public void serialEvent(SerialPortEvent evt) { if(this.getConectado()){ if (evt.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { byte singleData = (byte)input.read(); if (singleData == START_DELIMITER) { singleData = (byte)input.read(); if(singleData == (byte)0x00) { singleData = (byte)input.read(); //get the length

Categories : Java

Can the Java Metro stack be used in commercial closed source projects?
After some more research I found that the Netbeans framework is licensed with the same construct (GPLv2 and CDDL) and luckily the guys at Netbeans took the time to explain the how what and why a bit: Netbeans license FAQ Here is what they say about dual-licensing: Dual-licensing is the practice of distributing identical software under two (or more) different sets of terms and conditions. When software is dual-licensed, recipients can choose which terms under which they want to obtain the software. The two usual motivations for dual-licensing are business models and license compatibility. [...] Additional search for details about CDDL brought me to this site containing a nice summary: why the dislike for cddl Here is one of the parts relevant that is to my question: CDDL i

Categories : Java

How to avoid java.io.IOException: Attempted read on closed stream
Because you are calling releaseConnection() in your finally block, the input stream will no longer be available. If you do not expect the content to be large, you could read the data from the input stream into a buffer and return the buffer instead of the input stream. Otherwise, you will need to change your code to allow the called to process the data from the input stream before releasing the connection.

Categories : Http

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

Java GUI program called by c++ kills its c++ Console application's main thread when it got closed
You are setting the default close operation of the frame to EXIT_ON_CLOSE. This makes the program terminate - not just the JVM, the whole program - when the frame is closed. Use DISPOSE_ON_CLOSE instead of EXIT_ON_CLOSE.

Categories : Java

Screenshot of Mainform shows subform. How to make sure subform is closed?
The problem might be that the main form didn't have time to repaint after the subform closed. this.Update(); will force the Form to repaint (http://msdn.microsoft.com/en-us/library/system.windows.forms.control.update.aspx)

Categories : C#

How to draw closed spline 3D (closed curve 3d) through unordered list of points3D. How to arrange points3D?
It sounds like you're looking for the Concave Hull of the data set. Unfortunately, I don't know of any pre-canned algorithms, but the link references a paper that another developer was starting from, as well as some sample code, so maybe that'll help you in the right direction.

Categories : C#

The underlying connection was closed: The connection was closed unexpectedly wcf service
The first thing i will do is, instead of returning the full list of candidates i will return an empty list. If that works fine, then it is very clear that the size of the data is a problem. To modify the size play with your binding parameters.

Categories : Wcf

"The underlying connection was closed: The connection was closed unexpectedly"
The first request does not utilize a header that indicates the length of the result. It closes the connection when it finishes. The second request utilizes the length header, reads the designated number of bytes, then closes the connection gracefully. (under the client side control instead of server driven disconnection) -or- The url you sent caused an error on the server. Is there an error in the server log or event viewer?

Categories : C#

How to make Exe of Java Project which run on PC without java installation
There's GCJ: GCJ is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile Java source code to Java bytecode (class files) or directly to native machine code, and Java bytecode to native machine code. Nevertheless, this solution is far from perfect and probably only applicable to a limited subset of projects: lack of support for Java 1.5 and higher (but maybe here retrotranslator can help) very partial AWT support. library has several packages from the standard java class library still missing

Categories : Java

Java how to make many buttons?
You hanve'nt added them to frame. Try for(int i=0; i < 5; i++) { JButton btn = new JButton(); //System.out.print(i); btn.setText("Button " + i); frame.add(btn); //adding to frame System.out.print(btn.getText() + " "); } After the loop do not forget to call repaint and revalidate to see the changes.

Categories : Java

How can I make a empty Mat using java?
Can't test right now but it should be something along these lines: Mat result = getPerspectiveTransformation(scene_corners,W,H);//assuming you also have H somewhere Mat getPerspectiveTransformation(Point[] points, int w, int h) { Point[] canonicalPoints = new Point[4]; canonicalPoints[0] = new Point(w, 0); canonicalPoints[1] = new Point(0, 0); canonicalPoints[2] = new Point(0, h); canonicalPoints[3] = new Point(w, h); MatOfPoint2f canonicalMarker = new MatOfPoint2f(); canonicalMarker.fromArray(canonicalPoints); MatOfPoint2f marker = new MatOfPoint2f(points); return Imgproc.getPerspectiveTransform(marker, canonicalMarker); }

Categories : Java

Java - How to make a variable that can be used anywhere?
This local inner class because defined inside method. Rules for local inner class are: A local class has access to the members of its enclosing class. In addition, a local class has access to local variables. However, a local class can only access local variables that are declared final. In this case quitVar is local variable, so you need to declare it as final to access it inside local class. But if you declare it final, you can't increment. If you want this variable accessible, then define as class variable rather than local variable.

Categories : Java

How can i make this GridLayout in Java?
This would give you your desired result: final JPanel mainPanel = new JPanel(new BorderLayout()); final JPanel bottomLeftPanel = new JPanel(new GridLayout(3, 1)); //add 3 panels to bottomLeftPanel final JPanel bottomRightPanel = new JPanel(new BorderLayout()); final JPanel bottomPanel = new JPanel(new GridLayout(1, 2)); bottomPanel.add(bottomLeftPanel); bottomPanel.add(bottomRightPanel); final JPanel topPanel = new JPanel(new BorderLayout()); mainPanel.add(bottomPanel, BorderLayout.CENTER); mainPanel.add(topPanel, BorderLayout.NORTH);

Categories : Java

Is it possible to make 'generic' casting in Java?
It depends what you want. This would compile: if (value instanceof Component) return (Component) value; return this; But the meaning would change a bit. It would return the value also for other components than the given three. This will be equivalent of your code, but a bit shorter: if (value instanceof JTextField || value instanceof JComboBox|| value instanceof JCheckBox ) return (Component) value; return this;

Categories : Java

Can't make instance from java class
You should change this line: SigninPerson SIPerson = null; new SigninPerson(s1,s2); to: SigninPerson SIPerson = new SigninPerson(s1,s2);

Categories : Java

How to make java use millimeters instead of pixels?
If you know the resolution - px/cm you can do the calculation in centimeters I guess. However, printers and displays have different resolutions based on the hardware itself. In Photoshop for example you can define how many pixels per inch you desire. Whether a printer can actually print the defined density depends on the printer itself. As an extreme example think about a 46 inch television and your smart phone. Both claim 1080 hd images but clearly the size in inches is drastically different.

Categories : Java

Java VisualVm make the PID disappear
is not a problem. When java process terminates you no longer can connect to it. you could run the same code 1000 times and make a snapshot in visualVM to analyze usages of memory, computations, etc. You'll have to divide the results by 1000. This gives you better results (taking time of 1000 runs and getting average), since single run can take different time at each run.

Categories : Java

How i could make a jess rule in java
This problem isn't a good fit for Jess as written (the Java code is short and efficient as-is) but I can show you a solution that could be adapted to other more complex situations. First, you would need to define a template to hold Date, int pairs: (deftemplate pair (slot date) (slot score)) Then you could create some facts using the template. These are somewhat equivalent to your date1, date2, etc, except they associate each date with the corresponding var value: (import java.util.Date) (assert (pair (date (new Date 113 4 10)) (score 1))) (assert (pair (date (new Date 113 4 25)) (score 2))) (assert (pair (date (new Date 113 4 5)) (score 3))) We can define a global variable to hold the final, computed score (makes it easier to get from Java.) This is the equivalent of your var varia

Categories : Java

How to make java wait for an event?
Hopefully you figured this out a while ago, but just for completeness: Your game has to run off events on the GUI. Specifically, your AI move code has to be run in response to the click where the human player makes his move--in the implementation of the ActionLister's actionPerformed method. You need to think in terms of the GUI--buttons and things--not in terms of game flow. Or rather, you've got recreate proper game flow building on GUI events.

Categories : Java

Make a Java Call from within Progress 4gl
You can call external shared libraries. http://documentation.progress.com/output/OpenEdge112/oe112html/ABL/wwhelp/wwhimpl/common/html/wwhelp.htm#href=Programming%20Interfaces/15dvpinch08epi.089.5.html&single=true You could, for instance, use that capability to create a "shim" to your JAR.

Categories : Java

How to make threads in Java run concurrently
In multithreading, usually you can't make any assumption about the output. Perhaps the time used to create the thread is very long, hence the previous thread has time to complete entirely, since its execution is very short. Try with 7000 and 5000 instead of 7 and 5.

Categories : Java

How to make a Java File Reader
use the filereader to read the file use the regex to split into words BufferedReader br = new BufferedReader( new FileReader( "file.txt" ) ); try { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while ( line != null ) { sb.append( line ); sb.append( ' ' ); line = br.readLine(); } String everything = sb.toString(); String[] words = everything.split( "[^\w']+" ); System.out.println( words ); } finally { br.close(); } }

Categories : Java

how do you make both arrays correlate in java?
You can use java.util.HashMap (or some other java.util.Map implementation). Map<String, Double> menu = new HashMap<String, Double>(); menu.put("Whopper Meal", 5.79d); //..and so on.

Categories : Java

How to make custom Java/JavaFX console?
I think you have to load the form before you can get the controller instance FXMLLoader loader = new FXMLLoader(this.getClass().getResource("Console.fxml"),resourceBundle); Parent p = (Parent) loader.load() controller = loader.getController(); Scene scene = new Scene(p);

Categories : Java

Make String first letter capital in java
You should have a look at StringUtils class from Apache Commons Lang lib - it has method .capitalize() Description from the lib: Capitalizes a String changing the first letter to title case as per Character.toTitleCase(char). No other letters are changed.

Categories : Java

how to make a java program to autoexecute by eclipse
You could create an Eclipse plugin and launch it on start up using this extension point. Since it is a plugin, it should shut down together with Eclipse automatically. However, this approach is deprecated and discouraged in the FAQ. Still, it would probably work if you only need this for yourself.

Categories : Java

java - How to make the list go beside each other (horizontally) instead of going down (vertically).
Use : System.out.print("Value"); instead of : System.out.println("Value"); And don't forget to add a System.out.println(""); at the end to flush the buffer.

Categories : Java

Set IDEA to make Java-based suggestions?
settings > code style > java > code generation > naming but putting m at the front for a method goes against convention. It sounds like a borked version of hungarian notation.

Categories : Intellij Idea

AppConfig.java? trying to make this dynamic not static
Ok from what I understand you are looking for the best way to store user entered URL's, which your app will use to access a database. If the app will only allow the user to have 1 server, the best way is to store the URL in a android Shared Preference. SharedPreferences are basically just settings your app can store values in. A very basic database, and very easy to use. It would look something like: SharedPreferences settings = context.getSharedPreferences(0); SharedPreferences.Editor prefEditor = settings.edit(); prefeditor.putString("user_url", url); If the app is going to support more than 1 URL you should use a database. (You could use the method above and just store multiple shared preferences if there will only be 2 or 3 urls available, but it's hacky and not scalable). For

Categories : Android

Technique used in java to make string immutable?
String class in Java is already immutable. For reference, see the documentation at http://docs.oracle.com/javase/7/docs/api/java/lang/String.html If you want to see how Java String class is implemented, please visit http://docjar.com/html/api/java/lang/String.java.html

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.