Java

98K

Solutions

59

Articles & Videos

32K

Contributors

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

Share tech news, updates, or what's on your mind.

Sign up to Post

Should I use Ecllispe or Android Studio to develop Android application ? Any good resource for starter to build an Android application ?

Thx
0
Free Tool: Path Explorer
LVL 8
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I have below entity class which Im saving to DB based on LogType enum

@Entity
@Table(name = "AuditLog")
@Getter
@Setter
public class AuditLog implements Serializable
{
  
    private static final long serialVersionUID = 1L;
   
    @Id
    @Column(name = "AuditLogId", nullable = false)
    public Integer            importId;
	
    @Column(name = "AuditLogDescription", nullable = false, length = 1000)
    public String             logMessage;
 
 
    @Column(name = "EntryDateTimestampJoda", nullable = true)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public DateTime           entryDateTimestampJoda;
   
       
    @Column(name = "ExitDateTimestampJoda", nullable = true)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public DateTime           exitDateTimestampJoda;

}

Open in new window


And im calling it like based on Enum Value as below however Its the same repeatative code that gets called in below if condition,

private void processLoggingData(LogData logObj, LogType type)
{
	if (type.toString().equalsIgnoreCase(LogType.LOG1_PROCESSING.toString()))
	{	
			AuditLog audObj = new AuditLog();
			audObj.setImportId(logObj.id);
			audObj.setLogMessage(logObj.description);
			audObj.setEntryDateTimestampJoda(logObj.getStartDateTime());
			audObj.setExitDateTimestampJoda(logObj.getExitDateTime());
			

Open in new window

0
HI,

I have a java program that writes out files in both Linux and Windows directories.

I unfortunately have to create file names that have a slash in them "/".

How do I create windows and Linux files with a forward slash "/" in them?

Here is an example of one of those file names: Test123/tst45#48

Thanks,

Chris
0
I have to store a value(time since 1970 in milliseconds) in a custom map. The methods that i could use are setDouble(index, double) and setInt(index, int). Sadly there isn't a setLong(). I tried storing as int, after casting the long to int, but it is loosing information. Can I absolutely sure that casting the long to double will not lose information? Please give me the code
long Value is 1495695600000
0
Hi,

Trying to Convert BASE64 String to Float array.

Input : <values byteorder="INTEL" format="FLOAT32" numvalues="74">MsHjPwc65T/csuY/sSvoP4ak6T+9Les/CKzsP8kv7j8Uru8/6SbxPzWl8j/2KPQ/y6H1P4wl9z/X
o/g/mCf6PwuQ+z+R7fw/exT+P7QP/z+7AgBA/40AQFYOAUCGpAFA50ICQKrxAkCLswNAa3UEQEw3
BUAs+QVADbsGQDN6B0CdNghAfvgIQKO3CUDJdgpA7jULQBT1C0B+sQxAX3MNQIQyDkCq8Q5AFK4P
QH9qEEDpJhFAD+YRQHqiEkCfYRNACh4UQC/dFEBVnBVAelsWQKAaF0CA3BdA65gYQBBYGUB7FBpA
oNMaQAuQG0B1TBxAmwsdQHzNHUChjB5ADEkfQHYFIECcxCBAwYMhQCxAIkAMAiNA7cMjQFeAJEB9
PyVAov4lQA27JkA=

        </values>
        <Ydata label="Intensity" units="UNKNOWN">
          <values byteorder="INTEL" format="FLOAT32" numvalues="74">AGiERQBYCkYAwHNFAOi7RQCYyEUAQJBFAAw5RgCQQUUAwPZEAFjrRQAMo0YAbvBGAHtqRwDMzEdA
CCZIwD1mSGDanUig851IoFuNSODFpEgAQaRIQFurSIA2i0iAHW1IwD9/SMB/O0jADhRIALDOR4A5
wEcAIpxHADJaRwCkJ0cA9AxHAJbdRgBE4kYADKdGAJCGRgAUZEYA2E1GAIBMRgDAdEYAIK9FAOAB
RgAY8UUAiKxFADj7RQDwFkYAaOhFAIjMRQCcNEYAeM9FAGipRQDgokUA8HVFAEAzRQCgMEUAkL9F
AMgpRgDwxUUAWJhFAKAqRQDAA0YA0KlFAHBxRQBg4kUAMDlFAIBSRQB4k0UAKNFFAFQGRgDkGkYA
0AdFAIDARQBQt0U=

          </values>
Here want to convert the string inside the Values tag into Float Array.
If i would take value -
( MsHjPwc65T/csuY/sSvoP4ak6T+9Les/CKzsP8kv7j8Uru8/6SbxPzWl8j/2KPQ/y6H1P4wl9z/X
o/g/mCf6PwuQ+z+R7fw/exT+P7QP/z+7AgBA/40AQFYOAUCGpAFA50ICQKrxAkCLswNAa3UEQEw3
BUAs+QVADbsGQDN6B0CdNghAfvgIQKO3CUDJdgpA7jULQBT1C0B+sQxAX3MNQIQyDkCq8Q5AFK4P
0
Hi,

I have a C program which would be doing some task and returning a value to me. I would like to capture this value either in CL or in Java code. Anyone having any idea how I can accomplish this?
0
I'll try to explain my problem. I have an array containing a list of over 5,000 music artists. I have a list of RSS feeds which contain details of news articles. I'm trying to loop through each news artist and see if any of the 5,000 artists are mentioned in an article.

So, for each article I'm trying to perform a search on the description + title of each entry in an RSS feed.

Initially I tried the string.contains options, but this returned false positives (matches where the artist is in part of a full works). i.e. it will find a match for 'Boston' in a string that contains 'BostonCrew'.

I then tried using a regex boundry, but this only seems to match a single word, i.e. 'Boston' to 'Boston', but doesn't seem to match 'Tiger Woods' when it's in the string being searches.

How would I perform a search on a string for either a whole word, or a hole combination of works. i.e. Boston' should match when the full word 'Boston' is in the string, but also 'Tiger Woods' should match when the whole string is found. But at the same time wouldn't match 'Tue' where the word 'Tuesday' is in the string as it's not a whole word or combination of whole words.
0
Hi, I am creating a mobile app and in my MainActivity class in android studio and I'm trying to call a method that is within an inner fragment class.  Within this fragment class I have another class called WebViewInterface:

public class tab2_upgrade extends Fragment {

    Context context;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.tab2_upgrade, container, false);
        WebView webView = (WebView) view.findViewById(R.id.webView);
        webView.loadUrl("file:///android_asset/tab2.html");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.addJavascriptInterface(new WebViewInterface(), "Android");

        return view;
    }

    public class WebViewInterface {

        @JavascriptInterface
        public void showToast(String message) {
            Toast.makeText(context, message, Toast.LENGTH_LONG).show();
        }

Open in new window


But when I try to access this inner class to call a method within it from my MainActivity I get an error as if it does not recognize it (but can find it):

    @Override
    public void onProductPurchased(String productId, TransactionDetails details) {
        tab2_upgrade tab2 = new tab2_upgrade();
        tab2.WebViewInterface tab2WebView = new tab2.WebViewInterface();
    }

Open in new window


or

    @Override
    public void onProductPurchased(String productId, TransactionDetails details) {
        tab2_upgrade tab2 = new tab2_upgrade();
        tab2.WebViewInterface tab2WebView = tab2.new WebViewInterface();
    }

Open in new window


Could someone please tell me why I am getting this error and how to fix this so that I can access the WebViewInterface class in my fragment class??  Please see the attached images to see the errors in red.  Thanks
webinterface_error.png
webinterface_error3.png
webinterface_error4.png
0
How to parse the  JSON Data using Rest web service give me a simple example
0
Difference Between Path Parameter and query parameter in web service
0
What Is Transaction Monitoring and who needs it?
LVL 1
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Hi Experts,

I have created a google rest api call using postman and can successfully retrieve an email from my gmail account. However, I need to extract some text from the body and it is coming back encrypted such as below

 "body": {
          "size": 2717,
          "data": "PCFkb2N0eXBlIGh0bWw-DQo8aHRtbD4NCjxoZWFkPg0KPG1ldGEgY2hhcnNldD0iVVRGLTgiPg0KPHRpdGxlPkNvbXBsZXRlIHlvdXIgUmVnaXN0cmF0aW9uPC90aXRsZT4NCjwvaGVhZD4NCg0KPGJvZHkgc3R5bGU9ImZvbnQtZmFtaWx5OkdvdGhhbSwgJ0hlbHZldGljYSBOZXVlJywgSGVsdmV0aWNhLCBBcmlhbCwgc2Fucy1zZXJpZjsgbGluZS1oZWlnaHQ6MS42ZW07IGZvbnQtc2l6ZToxNHB4Ij4NCjwhLS1baWYgbXNvXT4NCgk8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCQlib2R5LCB0YWJsZSwgdGQge2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIHNhbnMtc2VyaWYgIWltcG9ydGFudDsgbGluZS1oZWlnaHQ6MS42ZW07fQ0KCTwvc3R5bGU-DQo8IVtlbmRpZl0tLT4NCgk8dGFibGUgc3R5bGU9InBhZGRpbmc6MTBweDsgd2lkdGg6YXV0bzsgbWFyZ2luOjAgMTAlIj4NCiAgICAJPHRyPg0KCQkJPHRkPg0KCQkJCQk8cCBzdHlsZT0idGV4dC1hbGlnbjpjZW50ZXI7Ij4NCgkJCQkJPGltZyBzcmM9ImNp.........

Open in new window


Has anyone had experience extracting data from the body or can offer any suggestions on how I can convert the data field into someting rreadable

Thanks
0
I have searched the android developer docs (and made lots of google searches) but I cannot find anything that shows what the code is exactly for turning off the 'Motion Effect' when setting a wallpaper. Apparently I am looking in the wrong directions or just completely missing something... but could someone please show or point in the right direction for how to turn off the 'Motion Effect' when setting the wallpaper from an app?

I see how to do this when manually setting my own wallpaper on my phone using android's ui but I cannot find java code that does the same thing (for example using the WallpaperManager or something similar).  Please see attached image.  Thanks
wallpaper_motion2.jpg
0
I am trying to override a method whose description is as follows
public void onSourceUpdated(Settings settings,  java.util.Map<java.lang.String, java.lang.Object> fields)

Open in new window


I am trying to override it as below but it does not allow
@Override 
	public void onSourceUpdated(Settings settings, Map<String, Object> fields){

Open in new window


however it takes the below
@Override 
	public void onSourceUpdated(Settings settings, Map fields){

Open in new window


Why does this happen?
0
Hi,

What is the use of below command from eclipse project by right clicking and run as "maven build.."

what is meaning of shade why we need to give in the goal?

please advise
0
I am trying to access a DELL storage device and it says "Group Manager requires Java SE 6 Update 31 or later.  Would you like to update now?"  When I click OK, I am getting "page cannot be displayed message".  

I go to this link http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html and click on jre-6u45-windows-x64.exe under Java SE Runtime Environment 6u45 but it says I must accept the license agreement before downloading.  

I do not see a button to click to agree.

Please advise.  

Thanks.
0
public InputDependency(java.lang.String src,  java.lang.String... dependentFields)

Open in new window


How many dependentFields will this take?
0
HI,
Following is an example from effective java joshua bloch :
 // Naive generic version of reduction - won't compile!
   static <E> E reduce(List<E> list, Function<E> f, E initVal) {
       E[] snapshot = list.toArray();  // Locks list
       E result = initVal;
       for (E e : snapshot)
           result = f.apply(result, e);
       return result;
}

Open in new window


And he mentions :
The compile- time type of snapshot is E[] which could be String[], Integer[], or any other kind of array. The runtime type is Object[], and that’s dangerous.

The compile time type could be String[], Integer[]  that is understandable as user will pass a String[] or integer[]  etc...
But what does it mean the runtime type is Object[] and why is that..
wont user will pass a String[] for example to the method param.. Then during runTime also the type will be String[] ?

what exactly does it mean ?
0
HI,
I have the following example from joshua bloch book Effective java :
// List-based generic reduction
   static <E> E reduce(List<E> list, Function<E> f, E initVal) {
       List<E> snapshot;
       synchronized(list) {
           snapshot = new ArrayList<E>(list);
       }
       E result = initVal;
       for (E e : snapshot)
           result = f.apply(result, e);
       return result;
} 

Open in new window


What the function aims to achieve can be done directly looping over the list.. But here we create a synchronized block and make a copy of the list.. and then we loop over it.
Whats the reason for that...
I think its probably got to do with multithreading...So that other threads using the list dont modify it while we are iterating the list in this method...
If that is the case then should all methods which have list in there parameter make a copy of the list ??
we dont see such locking happening everywhere.
Thanks
1
Hi folks, I'm trying to retrieve several different results between some delimiters within a String, but haven't found how I'd go about it. Here is an example of what I need:

String a = “/abrter/12345234/!4$/abrter/9834574/!4$/abrter/1239874/!4$/abrter/98766474/!4$”;

How would you get the values between “/abrter/“ and “/!4$” ?
I know how to retrieve it if there is a single occurrence but how would I go about getting all the values?
I’d need to store the values: 12345234, 9834574, 1239874, 98766474 in a text file or an array.

Any help would be much appreciated.
Cheers.
0
Salesforce Made Easy to Use
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

I want to be a Game play Programmer. to be GPP I need to study in a good university.Good universities want good $$$.i want start my career for some years or some time.which career is best that give me more $$$.
1.Java EE/Java Developer
2.Mobile App Developer
3.UI/UX Designer
4.Internet Advertiser
0
HI,
In some places i have read that java does not allow generic array creation.
And indeed the following line gives a compilation error :
        Set<String>[] s = new Set<String>[10];

But i converted it to :
 Set<String>[] s = new Set[10];
        s[0] = new HashSet<>();
And i could add elements to s[0]
So in a way i have created generic array types...
Is there some flaw in it ?

Thanks
0
can you provide examples for encryption/decryption with e AES 128,AES 256,DES and 3DES algorithm  with Encoding: UTF-8, ECB mode
in JAVA using BouncyCastle api.
0
Hello,
I'm looking for the right findElement setting for the login button.  I had it working at one time with id="u_0_q", but then it stopped working.  I'm using Window 10 Edge Webdriver
What could work?  The first three lines are the DOM locator.  The first line looks to be a frame, before the login button.
The login button is that of www.facebook.com login
//<label class="uiButton uiButtonConfirm" id="loginbutton" for="u_0_q">
//<input tabindex="4" id="u_0_q" type="submit" value="Log In" data-testid="royal_login_button"
//></label>
				//driver.findElement(By.xpath("html/b[b]/b]ody/div[1]/div[1]/div/div/div/div/div[2]/form/table/tbody/tr[2]/td[3]/label/input")).click();
		//driver.findElement(By.cssSelector("input[data-testid=royal_login_button]")).click();
		//driver.findElement(By.id("u_0_q")).click();
		//driver.findElement(By.cssSelector("input[value=royal_login_button")).click();//absolute not work
		//driver.findElement(By.id("loginbutton")).click();//works for Edge!
		//driver.findElement(By.id("loginbutton")).click();

Open in new window

0
I'm trying to migrate an android application from dropbox's now deprecated api v1 to the current api.
My question is, does the new api provide a way to upload a file and then replace an existed file with the same name?
Old api had method putFileOverwrite(), but I don't see anything helpful in the new api.
0
Hi,
I have a java spring project in Intellij Idea. I want to search for all files which contains nested classes. Is there a way to do it ?

Thanks
0

Java

98K

Solutions

59

Articles & Videos

32K

Contributors

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.