This question already has answers here:
How do I "decompile" Java class files? [closed]
(19 answers)
Closed 8 years ago.
I would like to know if Java code is decompilable? Because I am doing an app for Android and i'm wondering if using the mysql connector is safe or not?
Talking about the java code into an android application.
Thanks for your answers.
Your question is a nice example of the XY problem. It seems that you intend to, actually, have an android app use a database. Decompilation is the least of your worries. A user can use a packet sniffer to also get your authentication details in some cases. A simple strings foo.apk search can come up with the DB authentication details. Someone could hit your DB server from outside irrespective of your app;
A more viable solution would be to set up a web server that can handle untrusted requests and forward them to the database after filtering them. Then, you no longer have the risk of people stealing your DB credentials from the APK or device, since they no longer live there.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I would like to create a simple HTTP server in Android for serving some content to a client.
Any advice on how to build the server or use any existing library?
Consider this one:
https://github.com/NanoHttpd/nanohttpd.
Very small, written in Java. I used it without any problem.
NanoHttpd works like a charm on Android -- we have code in production, in users hands, that's built on it.
The license absolutely allows commercial use of NanoHttpd, without any "viral" implications.
This can be done using ServerSocket, same as on JavaSE. This class is available on Android. android.permission.INTERNET is required.
The only more tricky part, you need a separate thread wait on the ServerSocket, servicing sub-sockets that come from its accept method. You also need to stop and resume this thread as needed. The simplest approach seems to kill the waiting thread by closing the ServerSocket.
If you only need a server while your activity is on the top, starting and stopping ServerSocket thread can be rather elegantly tied to the activity life cycle methods. Also, if the server has multiple users, it may be good to service requests in the forked threads. If there is only one user, this may not be necessary.
If you need to tell the user on which IP is the server listening,use NetworkInterface.getNetworkInterfaces(), this question may tell extra tricks.
Finally, here there is possibly the complete minimal Android server that is very short, simple and may be easier to understand than finished end user applications, recommended in other answers.
Another server you can try http://tjws.sf.net, actually it already provides Android enabled version.
If you are using kotlin,consider these library.
It's build for kotlin language.
AndroidHttpServer is a simple demo using ServerSocket to handle http request
https://github.com/weeChanc/AndroidHttpServer
https://github.com/ktorio/ktor
AndroidHttpServer is very small , but the feature is less as well.
Ktor is a very nice library,and the usage is simple too
You can try Restlet edition for android:
The source can be downloaded from Restlet website:
This question already has answers here:
Is it possible to run C source code from Java?
(4 answers)
Closed 7 years ago.
I want to make a Java app that uses the Razer Chroma SDK, but the Chroma SDK is in c++
Is there a way I can run c++ code from Java?
I must use Java for what I want to make.
I have almost no experience in c++, but I understand enough to get doing what I need.
EDIT:
This question is slightly different then others, because it is about a specific SDK, not about general c++ libraries. For this library I was able to use a simpler approach then learning to use things like JNI
You probably want to look into using JNI
The easiest way I found, and then one that doesn't require learning stuff like JNI:
Create a console application with commands that fire off what you need
In Java, launch the console application and redirect it's input and output streams so you can send it commands, and log it's output (see 12013910)
Have a command in the console application that you can pass a PID, and have the console application watch for when it closes, and then it will close itself. (This fixes having the console application not being closed if the Java application crashes and doesn't call the closing method(s))
This question already has answers here:
Multiple clients access the server concurrently
(2 answers)
Closed 8 years ago.
I am having a Login screen demanding username and password to Login to a desktop application in java.
Now my problem is that suppose their are 2 or more users at the same time using my desktop application.Means their are two or more threads running at one time Now how to ensure that multiple clients access the server concurrently ?
I need to visualise it by printing which thread is running at present time.
So could anyone help me to do this
This is same question that you have asked already here Multiple clients access the server concurrently in the same context.
Solution:
Here each client is connected in a separate thread from server and that thread contains all the information about the client. It will solve your concurrency problem as well as you can store any information about the client.
Please have a look at my answer and let me know if you want to do differently here.
This question already has answers here:
how to get a client's MAC address from HttpServlet?
(5 answers)
Closed 9 years ago.
i want to identify a client machine uniquely from servlet.
Basically my application is about to take visitors detail. In my application i have offers for a user who visited me first time. In this scenario, i need to get information of client's machine so that if get back on site then my application can recognize that from this machine client is already visited.
I am using JAVA SERVLET.
Any point regarding this scenario will appreciated.
Thanks in advance.
Using only Servlet technologies, it is impossible to get MAC addresses. MAC address detection need software running on the client machine - a browser plugin, ActiveX control, JavaScript script or something like that. It would also most likely trigger security warnings, if the browser tried to access such information.
Cookies should be used as a first method of returning visitor detection. It is quite easy to clear them or use a different browser, but the majority of internet users don't think about such things.
Going for MAC addresses seems needlessly invasive to me.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've been going through a very frustrating time trying to distribute my program and I could really use some help.
So it all started a long time ago when I decided to try and teach myself C++. I thought I'd learn by doing by trying to create a text adventure with basic code. I managed to create an executable file that worked and cheerfully submitted it to a website that sometimes hosted content similar to what I created.
My submission was rejected out of hand, as no one wanted to advertise or even open the contents of a link to a file download from an unknown source. I found some information online saying that by using the Java Programming Language, I could run an application from a webpage using something called an "applet" that other people could access.
So I learned a second programming language and some basic html and tried to put my application on a website... Except it turns out that applets are a dying technology that no one trusts and that while it is possible to run a program as an applet (or a java web start application) from a webpage, modern browsers will scream bloody murder at anyone who tries to do so because applets are considered horribly insecure.
This project has now been ongoing in some form or another for over a year at this point, and I am at my wits end. I really, really don't want to have to write my program over again in yet another language just so that I can show it to people without them flipping out and acting like I'm trying to infect them with a virus. Is there any way at all to have people use my Java program for free on the internet in a way that won't give people terrible security messages?
It's not a question of programming language. As long as your goal is to distribute your code (meaning that users have to download your code and run it on their computers) you will face the resistance. I, for one, would not run anything downloaded from internet until I research it and find reputable evidence of it being legit and harmless.
You may want to have it as a web application that runs on your server and gives users options to download results in some acceptable format. PDF is usually considered safe, though it's possible to embed maleware there.
Java EE gives many options for creation of such app, starting with JSP (Java Server Pages) and including more up-to-date ones (JSF and such).