Java How to call JMagick from a web application

I have a servlet based application for serving stored documents and images. The images were all stored as jpg with standard sizes based on corporate standards at the time the system was designed. Now, the image sizes that users want to see have changed. Since there are many images that won't need to be resized, we have built a service to resize images on the fly based on an additional request parameter. The new file will then be saved for future requests. The files can be resized using java

Fetching remote objects add "_$$_javassist_x" to type

we have a client/server app (Flex and Java) that uses BlazeDS to do remoting. This allows us to exchange and map types between client and server. For some reason a User type we are retrieving from the server is not sent as "User", but as "User_$$_javassist_x", where x is an integer. The other types we are sending over all work fine, even the User type used in a different service class. Any ideas?

Avoid writing HTML by coding in Java

I want to avoid writing <table></table> and other stuff like that, by writing Java (or Python) classes. Example: Html html = new Html(); obj.setCoordinates(120,50); html.add(obj); Which API is the best for this ? Update I'm currently trying Vaadin, a Java web framework which extends GWT. It offers web functionality with a coding style similar to a desktop API.

Java Unicode characters not rendered when running jar file in terminal ( Eclipse / MacOS )

I have a Java project in Eclipse with ascii characters in it (◊ , ‡ , etc). When I export the project as an executable jar, and run that jar in the terminal (java -jar fileName.jar), the ascii characters are rendered as a '?'. It displays fine in the Eclipse console, but they aren't recognized in the terminal. I originally had it as just the character ( ◊ , · , — ) in the code, then changed it to unicode in hope of that fixing it (\u25CA \u00B7 \u2014) with no luck. It was the same scenario, di

Java/HTML - prevent outlook from wrapping text in table

I have a css defined as follows: body { font-size: 80%; font-family: Calibri; } table.gridtable { color:#333333; text-align: center; border-width: 1px; border-color: #666666; border-collapse: collapse; } table.gridtable th { border-width: 1px; white-space:nowrap; padding: 8px; border-style: solid; border-color: #666666; background-color: #dedede; } table.gridtable td { border-width: 1px; white-space:nowrap; padding: 8px; bor

Java Android pattern on top of 9patched BG png

I want to know if there is any easy way to apply this pattern: on top of this background: The problem is that the BG has borders, so the pattern cant get outside or be on top of the borders. It has to be exactly inside of the borders. Maybe this isn't even possible. What I want to achieve:

Java Adding custom ItemListener with EventHandler

I would like to add an ItemListener to a JComboBox, but with using the nifty EventHandler. Something like this: comboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // Do something } } }); in the form of: comboBox.addItemListener((ItemListener)EventHandler.create(ItemListener.class, target, method, event)); and then having a pulic method: public void

Java Skips input on second reiteration of method

In a learning program (I don't know much about this. It was to learn java) the output doesn't stop to get an input on the second iteration of the method which I have called getQ as this is a pub quiz. This is the code: import java.util.Scanner; public class pubQuizArray { private static Scanner kb = new Scanner (; static String[] questions; static String[][] answers; static char ans; static char yn; static char[] correctAns; static int questionNum; static int questionNumArray; static

Java Algorithm for clustering Tweets based on geo radius

I want to cluster tweets based on a specified geo-radius like (10 meters). If for example I specify 10 meters radius, then I want all tweets that are within 10 meters to be in one cluster. A simple algorithm could be to calculate the distance between each tweet and each other tweets, but that would be very computationally expensive. Are there better algorithms to do this?

Java Extracting a value, applying logic and printing the new value?

I have been scratching my head for a week trying to work out why my program isn't working as expected. I could give up and try something different, but I feel that I wouldn't be learning if I were to do that. Not only this, I feel to invested as I have spent ages getting to where I am now. If someone could give me a nudge in the right direction, the help would be geatly appreciated. The problem I have is that I cant extract the values of all the fields and then make a calculation (conversion i

Java Android: Use setContentView() after Thread finished

I want to use the setContentView() method after a thread has completed his task. But how could I realize this, as its not possible to use this method inside the thread? When using this method in the onCreate() method while the thread is running, I also don´t get the correct result, cause the layout wich should be displayed with the first "setContentView(R.layout.load_screen)" is not displayed. My onCreate() Method: protected void onCreate(Bundle savedInstanceState) { super.onCreate(save

Extract and convert blob field in image. MySQL - Java

I am writing a java program for fingerprint recognition, and I insert the fingerprint image in the MySQL database( in a field blob), but now is the problem. How do I go back to the image of the fingerprint? where I have to print it?( I presume in a canvas). help me please is very important, thanks to all.

Java How to index pdf file with lucene

i have to create a fulltext search with lucene in my project,so i have to index a blob column in mysql database(contains file pdf,doc,xsl,xml and image),with doc,xsl,and xml i dont have any problems but with the pdf file i cant get result public class Indexfile { public static void main(String[] args) throws Exception { RemoteControlServiceConnection a = new RemoteControlServiceConnection( "jdbc:mysql://localhost:3306/Test","root", "root" ); Connection con

How to send a string array as parameter to Java from xslt?

I am calling a java function from xslt which has a string array as a parameter. I tried to convert the string to array using : <xsl:variable name="strArr"> <item></item> <item></item> </xsl:variable> I get this error: could not find method com.techm.ump.applicationServices.Email.postMail([ExpressionContext,] #RTREEFRAG, #RTREEFRAG, #STRING, #STRING)" When I try to convert using : document('')/*/xsl:variable[@name='FMail']/* I

How to concatenate two or more big XML files in Java (not using memory)?

Our application needs to concatenate two or more XMLs files, one after another. The result should be another XML file. We can't store the XML into memory because these could be files of hundreds of MB. The application is made in Java with spring and spring-batch, but any other library could be also welcome. To clarify, this is my XML: Sample file: <item> <name>x</name> <surname>y</surname> </item> <item> <name>Z</name>

Java How to do hibernate mapping to mysql server through ssh tunnel?

I have to implement one java class, that will read data from mysql server. I am able to connect to mysql server through mysqlyog using ssh tunneling option. But when I tried it through code I am getting JDBCConnectioException: Error calling Driver#connect. Here is my hibernate mapping file: <property name="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </property> <property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver

Java Android Remote service not getting SharedPreferences

I'm having quite a bit of a problem in trying to get a sharedpreference value inside a service. I'm able to get the value from another activity and the shared preferences seems to be working fine when i'm running the service for the first time (I'm able to get the value that were saved) but if i stop the service and changed some preference and run the service again, I'm getting the preferences that were saved for the first time. From across an activity or a normal service, i'm able to get the

Java Eclipse 4 RCP (Luna) file association Windows

I'm trying to make work the File association with my RCP application based on eclipse 4.4 Luna. I followed this tutorial I got it working on Linux and Mac OS, but in Windows I can not load the file at first application startup. If the application is not launched and I open it with an input file, a new application instance is launched but the file is not loaded. Once an application inst

Java myData method cannot be resolved to a variable error

When I write myData method, its gives an error that It cannot be resolved to a variable. Here is the code. private class DownloadData extends AsyncTask<String, Void, String> { String myXmlData; protected String doInBackground(String...urls) { try { **myData** = downloadXML(urls[0]); } catch(IOException e) { return "Unable to download XML file."; } return""; } protected void onPostExecute(String

Coverting cURL to java for

I'm really struggling... The parse docs give this example on how to send a push, using curl: curl -X POST \ -H "X-Parse-Application-Id: myAppId" \ -H "X-Parse-REST-API-Key: myAppKey" \ -H "Content-Type: application/json" \ -d '{ "channels": [ "Giants", "Mets" ], "data": { "alert": "The Giants won against the Mets 2-3." } }' \ how would I do this in plain java, for a desktop java program?

Java How to access web.xml init parameters in JSP

I have stated my init parameter in web.xml and on accessing same in init.jsp I get output as null. I am using Tomcat-8 My web.xml is: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="" xmlns="" xsi:schemaLocation="" id="WebApp_ID" version="3.1"> <display-name>SecondWebProject</display-name> <

Java Write a string in Eclipse console in Bold?

I would like to write a String in Eclipse Console in Bold (just the "test.txt") ... System.out.println("the name of the file is ? test.txt"); Please this solution Font settings for strings in java is not working ! When I do : System.out.println((char)27 +"[1m testing bold"); I get : [1m testing bold I am using Java-8u40 so Eclipse Luna is using Javaw.exe ...

Java How can I through an editable textview populate a custom todo list using a custom adaptor?

I want a user to input data through an editable text and I want to receive that data through a custom made listview for that I am trying to use a custom adapter to add a textfield into my listview, through the tostring() method I have converted the data from the editable textview to a string and I am adding that string to the custom adaptor but I am having a type mismatch error, before this I added the string to a basic adapter and the listview was populating normally, what am I doing wrong? Us

ask : error to show Jtable from database with java.lang.NullPointerException

i've run my main method package com.dascom.view; public class Main { public static void main(String[] args) { new JFrameDatabarang().setVisible(true); } } and get error Connection succes Exception in thread "main" java.lang.NullPointerException at com.dascom.controller.DatabarangController.isiTable( at com.dascom.view.JFrameDatabarang.<init>(

Java, GUI IllegalStateException Error

I know this have been asked in someway state or form and I looked at others, but I can't find why I am getting this error message. I'm not too well studied with GUIs and this is one of my first GUI projects I am working with. Error Code: Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,horizontalAlignment=LEADING,

Java How to use AsyncTask for copy Database in Android

I want use AsyncTask for copy database in my application. The application has 4 fragments, and any fragment shows one table from the database (database has 4 tables). But when I run the application, it show me this error: 03-07 12:49:18.775 11190-11190/com.tellfa.dastanak E/AndroidRuntime: FATAL EXCEPTION: main Process: com.tellfa.dastanak, PID: 11190 android.database.sqlite.SQLiteException: no such table: tbl_Book (code 1): , while compiling: SELECT * FROM tbl_Book WHERE Cat_ID = ? at android.

Java, dependency injection singleton?

I have following code: public class DummyService { // Create new DummyModel with default value, // Set value read from config file private static final DummyModel INSTANCE = new DummyModel(Play.application().configuration().getString('some-value')); public static DummyModel get() { return INSTANCE; } } And I use it: DummyService.get().someMethod(); Now I'm trying to write unit test that use this DummyService, but this is hard since DummyModel static instance is create f

Java - creation of multiple object of a same kind and storing them in 2d arrayList map

I need to create 30 objects of the same kind and their name should start with a capital letter e.g "K" and after the letter i need the index of the object e.g K1 ; K2 ... K30 Is there any way to enter a loop which has a counter and which will work properly something like this for (int i = 0; i<20;i++){ K k = new K(); k.setName("k" + i) } I also have a map which is 2d ArrayList 20x20 and all this object need to have a random position x and y into this array list i could generate random num

Java 8 Stream - operations on objects with same id within Collection

My question is a bit complex (I think), so I'll try to use an example. Hopefuly you'll understand my problem. Set's say I have a List of users: List<User> users; Where: public class User{ private List<Car> cars; } public class Car{ private String code; private List<Feature> features; } public class Feature{ private String code; } What I want to achieve is get the list of Cars from the list of Users BUT I also want this list to be distinct (no cars with

Java find the sum of squares and cubes from 1 to 10

I'm new to Java and i'm trying to find the sum of squares and cubes from 1 to 10. But i only know how to find the sum from 1 to 10, i think they're kind of similar but i'm having trouble figure it out. public class sumNumber { public static void main (String[] args) { final int LIMIT = 10; System.out.println("The sum of the numbers from 1 to " + LIMIT + " is " + sumNumber(LIMIT)); } public static int sumNumber (int number) { int sum = 0; for (int i

Java Android Fingerprint Scanner, detecting the finger used for authentication

I'm looking to detect which finger is used for device authentication in Android Marshmallow. The callback used for getting the successful authentication is - onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) However I don't see how can I use the FingerprintManager.AuthenticationResult object to detect the finger used for authentication. Any help is appreciated on this.

How to extend the following Java class in Scala: class A<T extends Comparable<? super T>>

I need to extend a Java class (from a library) of the following type: public class A<T extends Comparable<? super T>> { } I tried to implement the extending Scala class as: class B[T <: Comparable[_ >: T]] extends A[T] { } Unfortunately, this Scala class does not compile with Scala 2.12.1: Error:(4, 25) illegal cyclic reference involving type T class B[T <: Comparable[_ >: T]] extends A[T] { How can I solve this problem?

Java installer issue on windows 10

I wanted to install simple JAVA JDK on it (that's 8u131 version downloaded from oracle's site). The problem is my installer doesn't work, this is it doesn't run, with no popping information, like it ignores the information about executing. Then I updated windows and graphics card but nothing's changed. Got no idea what's wrong. I've also tried different installers, downloading on a different pc and then executing it here, tried to install older versions of JDK but there was always no reaction fr

Java how to use onSaveInstanceState button that change the background layout?

I'm new to android develop. i just stated this week. i dont know if im asking stupid question but i want to learn. i have created an app just click a button change the background color. my layout is this <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="" xmlns:app="" xmlns:tools="" android:id="@+id/background" android:layout_width="

Show image in fullscreen in java

I've been trying to display an image in fullscreen mode in java with JFrame but I can't get it to work. When I create a new object of this a white window opens in fullscreen mode but the image does not get displayed: import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class DisplayManager { private JFrame jf; public DisplayManager() { //jframe jf = new JFrame(

Java How to pass int value from one activity to another and display in TextView?

I have an integer value in one activity, when I debug I can see there is a value be placed in. The value comes from a counter inside another function within the same class. I am trying to send the variable to another activity and display it in a TextView. Sending Class: Intent intent = new Intent(TrackingActivity.this, StatActivity.class); intent.putExtra("yzValue" , getyzVal()); startActivity(intent); Receiving Class: Intent intent = getIntent()

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException and how to fix it?

I want to create an application which chooses the number to be guessed by selecting an integer at random in the range 1-1000.The application then displays the following in a label: I have a number between 1-1000.Can you guess my number?Please enter your first guess. As each guess is input,the background color should change to either red or blue.Red indicates that the user is getting "warmer" ,and blue,"colder". import javax.swing.*; import java.awt.*; import java.awt.event.*; im

Java spring-security authenticates and creates principal but controller gets different invalid user instance

I just upgraded from spring-security 5.0.x to 5.1.3 and on deploying in-container I discovered that my services are not getting the authenticated user principal from spring-security. Instead it looks like spring-webmvc is instantiated another instance of my user principal, but without all the user and LDAP details provided by spring-security. I found one message from Spring that seems relevant but it says I need to migrate from th

Javafx "Grid is already inside a scene-graph and cannot be set as root" error

I am building a calculator and I want it to be able to switch between simple and scientific layouts for the user. It works for the "simple" scene. However, when I try to switch scenes to the "scientific" it gives me the error of the title. I am trying to set a BorderPane as the wrap and then put a "Settings" button on the Top and a GridPane on the Center. I did not set anything as a root. I know it must be setting something as root by default, but I posted this question because I don't understa

Java @RequestBody not parsing request into object for validation

I'm fairly new to Java/Spring and trying to set up an API Endpoint in an existing project. I've essentially copied some of the other endpoints that are currently working, but mine is not validating when being hit and it seems to be because the @RequestBody is not populating the object being fed into the method. I've tried removing @NotNull but it's still failing out. This seems odd given that other endpoints are working w/the @NotNull. import NotNull; public class SampleRe

Java Spring: Injecting list of all concrete classes implementing an interface

I have an @Service class which contains a List of other @Service classes. That List basically contains all the services which implements UniformEventsResearchApi. Being a rookie with Spring, I'm not sure how I can get Spring to allow me to follow the Open-Closed Principle and thus having that list automagically injected with all of the concrete implementations. Here is an incomplete UML class diagram: And here is some "code": @Service public class EventsResearchService { // todo: this

Java Invalid zip while compressing with ZipOutputStream

I get invalid zip, when writting to file the following code: public static byte[] zip(final Map<String, byte[]> mapReports) { try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(baos)) { for (Map.Entry<String, byte[]> report : mapReports.entrySet()) { ZipEntry entry = new ZipEntry(report.getKey()); zos.putNextEntry(entry); zos.write(report.getValue()); zos.closeEntry(); } return

Java Apache Poi Date value

i try to save type date at my database but i got this error java.lang.IllegalStateException: Cannot get a NUMERIC value from a STRING cell this is my code rfx.setRv_rc_date(row.getCell(67).getDateCellValue()); please what i should to do to get this value format date !

Java 8 Lambdas Map<String, String> to Map<String, Map<String, Long>>

I have a service that returns a response and maps it to a Map<String, String> object After this I need to calculate the key of the new map and insert as well all the keys that appear plus how many times they do. They key is calculated by getting the first character of the associated string. Key: A -> August/Air Key: B -> Boat/Big Example: Service response: { { "august", "red" }, { "air", "red" }

  1    2   3   4   5   6  ... 下一页 最后一页 共 6935 页