w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » JAVA » Page 4
Spring MVC with OSGi - how to register new controllers - second part?
It appears that you created a separate bundle with the Spring stuff or got it from somewhere. As a result the classpath of the bundle containing the FileSystemXmlApplicationContext class cannot see your local classes. Hence the ClasssNotFoundException. You can of course tweak with classloaders, for example by setting the bundle class loader to the thread before creating the Context, but I would s

Categories : Java

loop executing 3 times java
Instead of using Thread.sleep(1000); u can think about using this bit. Right after your do{ long startMili = System.currentTimeMillis(); and instead of your whole Thread.sleep(1000) thing put this in. long currentMili = System.currentTimeMilis(); while(currentMili - startMili < 1000){ long currentMili = System.currentTimeMilis(); } This will ensure this code will loop 1 time per sec

Categories : Java

JavaFX: Apply text color to TableCell using custom style sheet?
Since I don't know what type of object is in the cell, I'll use a Label. This is what you are doing: @Override public void start(Stage primaryStage) { TableView<Label> table = new TableView<>(); TableColumn<Label,String> column = new TableColumn<>(); column.setCellValueFactory(param -> param.getValue().textProperty()); column.setCellFactory((TableColumn

Categories : Java

HQL Hibernate un-related entities, but same id
You can map the join relationship between the two tables as follows: @Entity public class Verification implements Serializable { private Long verificationId; private Long salesManCode; private Long clientCode; ... } @Entity public class Contract implements Serializable { private Long contractId; @MapsId @OneToOne @JoinColumn(name = "contractId", referenc

Categories : Java

Cannot create connection from persistence.xml
You are deploying your application into JBoss that uses JTA and it already offers an XA Data Source. You shouldn't be using "hibernate.connection.driver_class" because that's only meant for simple development use cases (never for production deployments). If you were having a simple web application deployed into a web container (e.g. Tomcat) then you would have needed a resource local DataSource

Categories : Java

JTextArea - get the line of the current mouse position
Here is simple example with help of viewToModel() and getLineOfOffset() methods: import java.awt.BorderLayout; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.text.BadLocationException; public class TestFrame extends JFrame { pr

Categories : Java

Whats wrong with this java code
You are writing statements directly into the class body. You should put your code in a method like this: package other; import javax.swing.JFrame; public class Main { public static void main(String[] args){ JFrameClass obj = new JFrameClass(); obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); obj.setSize(275, 180); obj.setVisible(true); } } This should remove the errors.

Categories : Java

Combinations without repetition of a matrix
This is a basic idea to solve the problem: Use an array (or another collection) that will store the indexes that are used (the duplicates) For 0 to the last possible index available: Check if the index is already marked as duplicate If it's a duplicate, then move to the next index If it's not a duplicate, then Go to the next possible array Get the element at that index Add the index to the arr

Categories : Java

Adding a string to comboBox
In your code you declare comboBox as variable local to the method initialize(). That makes it visible only in the method where comboBox is declared. To make a variable accessible anywhere you could declare it as a static member of the class. public class gui_v1 { private JFrame frame; public static JComboBox comboBox; /** * Launch the application. */ /** * My inpu

Categories : Java

Start Volley Request whenever I want
I think you don't need to create diferent queues. You should just add the requests to the same queue. The answer chosen in this question could help you. What is the Maximum Size of the Volley-Library Request-Queue

Categories : Java

HTTP error 400 Bad Request when POSTing JSON data over HttpURLConnection
For the required data scheme, like this: JSONObject obj2 = new JSONObject(); JSONObject paymentMethod = new JSONObject(); paymentMethod.put("type", "neteller"); paymentMethod.put("value", "netellertest_GBP@neteller.com"); obj2.put("paymentMethod", paymentMethod); JSONObject transaction = new JSONObject(); transaction.put("merchantRefId", "20140203122501"); transaction.put("amount", (5000)); tran

Categories : Java

Properties instead of values in J2EE 7 Rest client
The object will be created (hence the constructor call), but if the field/properties of the class are not annotated correctly, the values will not be populated if matches can't be found (i.e. null values). Element attributes, should be annotated with @XmlAttribute. If you leave this annotation out, the properties will be default to @XmlElement. And if an element by that name can't be found, nothin

Categories : Java

Tomcat 7 startup failing with Java SE 1.7 in Solaris
(Too long for a comment) Why are you installing an EA release of an old version of Java ? (EA = Early Access release). Are you going for Java 32-bit or Java 64-bit? . If going for the latter (you should!) remember that in Java 7 this is distributed by Oracle as two install packages. First you'll need to install the 32-bit package and then install the 64-bit package on top of that. Install is si

Categories : Java

Calling non-default PLSQL object constructor function from Java
Inside PL/SQL you can call: declare t OBJ_DEPARTMENT; begin t := OBJ_DEPARTMENT(); -- this call of your first constructor without params end; / or declare t OBJ_DEPARTMENT; begin t := new OBJ_DEPARTMENT('Some value'); -- this call of your second constructor with 1 string param end; / new keyword is optional. Btw, why do you use dynamic SQL to get nextval from the sequence? In Orac

Categories : Java

Error 404: Issue accessing /WEB-INF/views/sendMessage.jsp. Reason: Not Found
After a long research I found this stackoverflow post. In my case changing the import org.eclipse.jetty.servlet.ServletContextHandler to org.eclipse.jetty.webapp.WebAppContext worked like a charm. In the end the Main.java file looks as follows. import java.io.IOException; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.webapp.Web

Categories : Java

Check if BigDecimal value is in range
Use BigDecimal.compareTo(val) to compare if your Number is bigger, smaller or equal. returns -1, 0, or 1 as this BigDecimal is numerically less than, equal to, or greater than val. if (price.compareTo(BigDecimal.ZERO) >= 0 && price.compareTo(new BigDecimal(500)) <= 0) { .... } else if (price.compareTo(new BigDecimal(500)) >= 0 && price.compareTo

Categories : Java

Return a string in a while loop
A StringBuilder can perfectly used in a while loop. Here is an example: public String toString() { int size = 10; int current = 0; StringBuilder sb = new StringBuilder(); sb.append("All values:"); while (current <= size) { sb.append(" current = " + current); current++; } sb.toString(); } The String returned by this method is: All values: current

Categories : Java

ArrayList Runtime error
Its a runtime error rather than a compile error. The format specifier types need to match the arguments return String.format("%s %s %d%n", super.toString(), " z-coordinate= ", getZ());

Categories : Java

Open application from a second Activity
you can save that option in SharedPreference and in your MainActivity's onCreate method change for saved value and then you can finish() your MainActivity and start SecondActivity put this in your onCreate method: SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPreferences.getBoolean("startFromSecondActivity", false)) {

Categories : Java

mediaplayer R file complications
If I understand your Question right, you want to do something like this: MediaPlayer[] playword; for(int i=0;i<2;i++){ int tmpSoundIdentifier = this.getResources().getIdentifier("sound_" + i, "raw", this.getPackageName()); playword[i] = MediaPlayer.create(this, tmpSoundIdentifier); playword[i].setAudioStreamType(AudioManager.STREAM_MUSIC); }

Categories : Java

In Java how do I evaluate XPATH expression on XML using SAX Parser?
Here is an exemple : //First create a Document DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new File("test.xml")); //Init the xpath factory XPath xPath = XPathFactory.newInstance().newXPath(); String expression = "/company/employee"; //read a nodelist using xpath NodeList nodeList = (NodeList) xPath.c

Categories : Java

Android: Errors occured during the build?
Such an error is a sign that you're combining the DexGuard plugin with an incompatible version of the Android plugin in Eclipse. You should check the compatible version numbers that are documented in the DexGuard manual. Upgrading both plugins to the latest versions should work.

Categories : Java

get substring from string Java(Android)
Explanation - youtube:(.*?)" matches for text in between youtube: and " public static void main(String[] args) { String s = "<p class="youtube_sc mobile "><a href="vnd.youtube:bMHJODdp7-U" title="YouTube video player"><img src="http://i.ytimg.com/vi/bMHJODdp7-U/hqdefault.jpg" /><span class="play-button-outer" title="Click to play video"><span class="play-butto

Categories : Java

dictionary in java using java.io
//This code is reading a file that is situated like this: Hello - to greet Circle - a round shape //Then the code can be done like so, is this ok? public static void main(String []args) throws IOException{ BufferedReader in = null; Scanner input = new Scanner(System.in); String str; boolean notfound = false; char again = 'a'; try{

Categories : Java

How to get integer value of a spinner value?
use the below code sample. int myNum = 0; try { myNum = Integer.parseInt(Spinner_NAME.get(position).toString()); } catch(NumberFormatException nfe) { System.out.println("Could not parse " + nfe); } How to retrieve the selected text from spinner ? Step 1 - In OnCreate Method, add this line. Spinner_NAME.setOnItemSelectedListener(this); Step 2 - In Activity cl

Categories : Java

Can't select between Maven installations in Netbeans
That would be a bug that you should report at https://netbeans.org/bugzilla (component project, subcomponent maven). Along with details of your setup.

Categories : Java

hibernate table per month
Uwe Allner already mention about archiving. You can archive to csv files as well. About the periodic backup process, you can use Quartz Shedular

Categories : Java

Java - file.length() returns 0
Please read the specs: The return value is unspecified if this pathname denotes a directory.

Categories : Java

Select div -class tag using Jsoup with Java
The documentation obviously says it is ok. Element masthead = doc.select("div.masthead").first(); // div with class=masthead So, I think _ is causing the problem. Try with div[class=article_text] as selector, and if that doesn't work then div[class^=article] (class starts with article), but it could select more than you would want. UPDATE div.article_text works on online Jsoup tester (http://

Categories : Java

In EJB 3.1, how technically does the container proxy and effectively spoof my no-interface object?
The container generates a proxy class that is a subclass of your no-interface EJB class, and then it overrides all of the methods to do its normal proxying (setup, teardown, and invoking an actual bean instance) rather than calling methods in your instance. Since java.lang.reflect.Proxy doesn't support extending a class, containers have to use another approach to generate a class, likely using a

Categories : Java

Create a jar with dependencies from bash
You can specify at runtime what JAR's you wish to be included with your JAR. In your case, the following should work. java -cp ../libs/1.jar;../libs/1.jar MyMain

Categories : Java

assign Integer type to int
Assuming that parameters.get("PO_PAGE_CNT") returns an instance of Integer, there is no problem with this assignment. It would be more readable to simply write : int x = (Integer) parameters.get("PO_PAGE_CNT"); An int can always be assigned to Integer (Boxing) and vice versa (Unboxing).

Categories : Java

Polygon with rounded corners
If you need rounded corners for arbitrary angles, Bezier curves are pretty much the worst possible choice, because the maths is stupidly complex. instead, let's use Catmull-Rom curves, because they're defined as "the curve goes through the following points: ..." instead of being simply controlled by points. For any 2 edges between 3 points, p1, p2 and p3, we can create new points p2l and p2r on t

Categories : Java

Android app need help connecting to a JAVA localhost server
You need tcp server socket communication > http://developer.android.com/reference/java/net/Socket.html

Categories : Java

How to output in JLabel if a JCheckbox is selected?
Well, of course it doesn't. setText takes a String as parameter, not a JCheckBox, which is what you are trying to pass. try this: if(yuan.isSelected() == true){ Converter.yuan(); label6.setText("yuan"); } even better, would be: if(yuan.isSelected()){ Converter.yuan(); label6.setText("yuan"); } the '== tr

Categories : Java

Need help accessing data file in Jar File
Where is your SoundDir directory located in the JAR file? Try unpacking the JAR file and checking if you are not sure. If your SoundDir directory is located in the immediately inside the JAR'd directory, then it is relative to the JAR root directory, and you need to use /SoundDir/sonar-beep.wav - note the leading slash. This makes the path absolute, or relative to root Without that slash, you ar

Categories : Java

how to access WorkManager attributes value in weblogic server from our application
You can access the JMX MBean: MaxThreadsConstraintRuntimeMBean to get information about your workmanager. JMX in Weblogic 12c: http://docs.oracle.com/cd/E24329_01/web.1211/e24415/accesswls.htm#JMXCU145 Runtime MaxThreadsConstraintRuntimeMBean: https://docs.oracle.com/middleware/1212/wls/WLAPI/weblogic/management/runtime/MaxThreadsConstraintRuntimeMBean.html

Categories : Java

Android .setColor for Large Icon
According to this: http://stackoverflow.com/a/27023679/327011 There is no way to change the Large Icon background when having both. The large icon should not be a transparent.

Categories : Java

java convert String windows-1251 to utf8
First java text, String/char/Reader/Writer is internally Unicode, so it can combine all scripts. This is a major difference with for instance C/C++ where there is no such standard. Now System.in is an InputStream for historical reasons. That needs an indication of encoding used. Scanner sc = new Scanner(System.in, "Windows-1251"); The above explicitly sets the conversion for System.in to Cyril

Categories : Java




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