Java - Executable JAR? Easy Decompiling? [closed] - java

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 2 years ago.
Improve this question
I recently started with Java and besides the variables, logical operators, loops and stuff like that I played around with JFrames and there are a couple of questions that comes to my mind.
I noticed that by saving my program as a executable jar the
program appears to be 1 file. Is that means when you're going to
develop a something that will use a many resources (images, audio
files & etc) they will be all stored in this jar file?
The second thing I noticed is that I can extract the jar file and decompile the .class files fairly easy. With that in mind let's say I use a MySQL database and to connect to the MySQL server I have to do it using JDBC driver and I ?must? hardcode the password?
Is Java suitable for 3D games? I'm really far from this, but let me know. I saw games written with a Java 3D game engine like jMonkeyEngine and I'm impressed, but I red (read) posts around that Java is slow and not that suitable for 3D games which leaved me a little bit confused.

You can do that, if you want. In Oracle's Java Tutorials you can read about creating executable JAR files: Packaging Programs in JAR Files
Any kind of program written in any language can be reverse engineered, so regardless of whether it's Java or not, you should never hard-code passwords. With Java byte code it's fairly easy to decompile.
More than 10 years ago, when Java was still young, it was relatively slow compared to languages that are compiled to native code directly such as C or C++. However, many advances have been made in the Java virtual machine over the years, and the performance of Java programs is comparable to C++ in many cases. People who still complain that Java is slow aren't up to date or don't have a lot of current experience with Java. Java is certainly fast enough, as you saw from demos with jMonkeyEngine. However, for commercial 3D graphics games, C++ seems to be the traditional de-facto programming language that's used. Note that to squeeze the last bit of performance out of the hardware, you'll need to write code specifically for that hardware. Java isn't the right tool for that, as it's designed to be platform-independent.

That is an option. It's certainly not mandatory, you can load resources from external files as well.
That's true. The common architecture for such an application is to put an application server in between the clients and the actual database. The application server that you control is what knows the database password. It only exposes to the clients the operations that they are supposed to be allowed to perform.
Minecraft is written in java, so QED. You won't likely be pushing the limits of modern GPU performance with a game written in Java, but that isn't the goal of every game.

Yes, you can put everything in one jar
Yes, but giving untrusted users raw access to database is rarely a good idea anyway. The better way is to build an server app with public API and authenticate users.
It depends. If you want to write an 3d app focused on rich, high-quality graphic effects than Java is probably not the best choice. However 3d in Java is easy and quite high-level, so you save lot of time on development compared to other lower-level technologies.

Related

Java for embedded systems? [closed]

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 2 years ago.
Improve this question
I have recently learned some basic Java and was thinking of seeing if I can use these new skills for an embedded computing project.
I have been looking around but I can't seem to be able to find any microcontrollers that are capable of running Java.
Does such a thing even exist?
Because of Java virtual machine architecture, you need considerable resources just to run the JVM. The path of least resistance to getting an JVM is probably to run an OS on the target that already supports it such as Linux, but that itself requires relatively huge resources.
There are a few stand-alone JVMs that either work bare-metal or integrate with and embedded RTOS for threading support. I compiled a list a while ago in an answer to a similar question, but some of the links are now out of date.
Running Java on an embedded system will certainly hit performance, and is probably not suited to hard real-time applications without a great deal of care.
Microcontrollers are not made for this use. Controllers called "mini computers" can embed JAVA applications (Raspberry PI, BeagleBone, Intel Edison, etc, because they embed an OS, and so can use JRE).
For microcontrollers, C/C++ are really better and more reliable.
Microcontrollers are meant for real low level - they normally don't have much functionality and won't have enough memory/processor speed to run JAVA.
Most entry level microcontrollers use C/C++ and maybe even their own variant of it.
Arduino/Atmega uses Haiku VM to run java. Using the haiku VM you can compile your JAVA code into C - and this will be programmed into Arduino. This makes debugging a little difficult, but it's not that bad - and hey, a high level language like JAVA cuts down your coding time a lot. Issue with this is normally your memory will get over soon, and you cant write huge pieces of code.
PIC - Muvium claimed support for PIC, but they stopped supporting it after a while and have closed down now. I don't think PIC has JAVA support for now.
Renesas is another popular microcontroller provider which has it's own SDK called MicroEJ for java o n RX and RZ boards of theirs. I've never used it, but their boards boast more RAM and flash memory - which helps a lot.
Single board computers (basically, a microcontroller/processor which is more powerful + has more peripherals) is useful when using JAVA for embedded programming. The two most popular ones are Beagle bone and Raspberry Pi. These are basically computers on a chip - and can run a full fledged ARM Ubuntu + Java/Python/any other language.
The easiest to use is Raspberry Pi (in my opinion) - which has huge community support.
Recently I started working on a CM12001/1000000 board that runs Java. It contains two controllers on the same board. Currently I do not have much knowledge of this thing. I will update the answer as soon as I get more info.
To answer your question: Yes, such a thing exists, but it is quite rare. Python however is gaining popularity in the embedded field recently using MicroPython, that includes a small subset of the Python 3 standard library and is optimized to run on micro-controllers.
Edit: ATOP Modules from Telit provide such functionality. Generally they have good amount of both RAM and Flash(A few MB to a few hundred MB). They run Linux over which they load JVM (as pointed by Clifford). Telit provides Java APIs to so control stuffs like GPIO (though very limited) and do stuffs like serial communications, GPS, GSM control etc.
Yes, microcontrollers that are capable of running Java on the bare metal exist
But JVM on this microcontrollers optimized for speed, and low memory usage. It's mean optimized JVM have some limitation instead of regular JVM, it's like Python and MicroPython
But pure code on Java allow you to transfer code with ease from the desktop to a microcontroller or embedded system
For self education with embedded computing project you can try to use Javaino
allow execute Java programs on this development board, read data from sensors via i2c, UART, etc like Arduino

How to create operating system using Java? [duplicate]

This question already has answers here:
Is it possible to make an operating system using java?
(6 answers)
Closed 6 years ago.
Is there anyway I could create a operating system using java? Is there anyway I could embed the windows java library so I could develop my OS with things like JFrame, JFileChooser, JTextArea, etc? Or would I be better off In the long run learning C or C++?
Yes, you can.
Many options available to do so:
JNI provides communication of Java code with native code. you can develop boot loader in native code, but UI in Java
Java Processor: implementation of JVM in hardware
Java Optimized Processors
Embedded Java
picoJava
and so on..
There's nothing that can stop you from developing OS in Java. You can find many OSes written in Java: from CISCO to NASA...
However, even creating a tiny OS requires a lot of effort.
Short answer: no.
First, Java using the OS to run your java code. A lot of the windows are using the OS to render.
Second, you should note that most, if not all, OS are started with machine/assembly code. If you have the goal of making an OS yourself and completely from scratch, you will need to learn assembly and there is no way around that. Luckily, you only need to write a small amount of assembly before you can get something written in C or C++ to run (and note that Java runtime is written in C/C++).
Since Java using the OS' native code to manage/render windows and controls, and assuming you've compiled Java from source without using said libraries, if you wrote your only code to handle all of the graphics of rendering controls and windows then yeah, suppose you could write a majority of the the OS in java once you got the basic stuff done. You should know that you wouldn't be able to use much of javafx or swing for anything since they rely on the OS.
Finally, I would strongly recommend going to college and getting a solid education , then I would further recommend working for a company with a team of experience programmers for at least 4 years (at minimum) before you take on such a herculean task as creating an OS. You aren't going to write a useful OS by yourself and with the amount of knowledge you seem to have in any language.
EDIT:
There are machines who's microprocessor natively understand java bytecode as mention in other answer. However an OS written for that processor would only work on that processor and would not be widely distribute atm. For learning purposes, you would be better just sticking with JVM on whatever you have access to now in you really don't gain much.
Also, learning to write an OS is a task I encourage all programmers to learn. It will give you a better understanding of how computers work inside and out. From a programming point of view, in relation to high level languages, you don't lose or gain much by using one language over another. Some argue (and perhaps I agree) that Java doesn't use pointer and so that is lost to most however if your intent is to do everything in Java, then all you need to understand is Java.
As a matter of opinion, I would argue you are better off learning every programming language you come across, and every language that are the predecessors to those. I don't mean become a master programmer in BCPL or COBOL or anything on that level, but at least research, learn how to do basic things and know they exist and (in most cases) can do everything every other language can do.
My professional advice, learn and master what ever language your employer would have you use. If you change jobs be prepared to learn something new. Not all jobs use Java, or C++ so if you limit yourself to just Java or even C/C++ you will not be as marketable on the job market.

Common tool to build app using any platform [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Applications can be build using any of these platforms (C#,vb,java), Is there any specific tool that supports development of app for any of these platform. For example why is that a cab file project or exe is developed using visual studio and android application are developed using eclipse which gives us app with .apk extension. for example if we have to concentrate our code developed using C# or vb or java , it has similarity except that it changes the syntax or naming nomenclature to define data or subroutine call. like printf in C, write or writeln in C# or println in java. or stream classes like filestream, or inputstream and outputstream,bufferedstream.........etc..... Is it that one tool for all application in the world . compiler does a common functionality in all this tool then why cant we have a common tool?
We wished for a tool xyz that supports C#,Java,vb or any other platforms and that has inbuilt virtual machine that has emulators to supports it respective apps. Also the result file must be of standard format with a standard extension that supports all types of OS Instead of exe,or cab or .apk or .dll . Just a thought . we have standard format for data tranfers via web , why not this
The issue with the tool:
MS Editor or any other basic text editor allows you to write applications in any of the mentioned plattforms. You then just need the required plattform base (like the JDK) as well as the compiler and interpreter of all of those plattforms. (Not to mention a Host-OS supporting the compilers/ interpreters).
Now that thats been said ("Yes there is a Tool for all of them"), i think it is only logic that IDEs focusing only on certain plattforms. Most of them will also allow to write applications in similar plattforms, like eclipse will support C, C++, C#, Java and so on.
This i guess is the case because most of the developpers on the market are specialized on one plattform only.
It is not that it is not possible to go any further into that direction but more that with any plattform supported complexity of the UI will increade (so will the available Short-cuts)
and thatfore lowers the usability of the IDE itself.
A simple example would be a view in the UI where you configure your Debug-Settings for local debugging. Would you implement it with tabs for each plattform or try to build a generic UI for all of them? It would lead to tabs i guess because debugging information of Java programm will surely require different configurations than when it comes to debug a Eiffel Programm.
So we would have a IDE that is
to complex to use as Beginner
to complex to find the required things as specialist of Plattform XY
to slow when it comes to handle the filesystem state for multiple projects using different plattforms.
to complex to develop and keep track with all the requirements of SWEs of the different plattforms.
to complex to maintain all the changes in the different languages supported.
But i gladely be teached wrong and try out such an IDE.
The nature of the plattform
(Answer to Question: "What about the deployment", see below)
See most programming languages are designed to work with certain operartion systems (like Visual Basic works with MS Windows), because those operation systems provide a bunch of APIs and allow you to use their "core"-functionality like "copy a file from dir a to dir b". The sequence of 0s and 1s (as faar as i know any OS basicially needs assembled 0/1s unless its a quantum computer or a machine one would not commonly describe as "computer") beeing executed by a CPU to copy a File from A to be will defently differ on Windows, Unix, OSX etc.
By its nature it will in my eyes never make sence to have a Java Programm beeing represented in Eiffel or Fortran even thus there are Projects working on "Programming Language A to B translators.
But i dont think that is what you are thinking of right, you just want to sit at one computer only and be able to deploy and run all kind of programms on it.
Since the different plattforms will require different operation systems or an according environment to run on them (like Java can be run on OSX, Windows, Unix etc.) you would need something like a virtual machine per desired plattform.
When it comes to super old programming languages or stuff that "wont run on your OS" there oftenly is Emulators available that bring the needed things with them.

Restful web application, Java or PHP? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm creating an Android application which will access data using a restful web application.
I have quite a lot of experience with Java, but minimal experience with PHP.
Having looked online, it is difficult to determine which language is more suitable, scalable, portable etc.
I'm hoping that the Application may one day have many concurrent users and therefore I need the most suitable option.
If anyone has any experience writing a web application in either language, I'd be really interested to hear about your experiences, and any problems you faced.. i.e. for a java web application do you need a tomcat server or another embeddded to server for it to be able to run?
Thanks, for any answers, Matt.
If you already have experience with java, I would suggest you use the following to build your REST services: http://restlet.com/
Its very easy, and efficient. The performance is very smooth. For PHP, you will have some learning curve, and also there is no standard. Mixing java with PHP is like combining a VERY STRICT LANGUAGE (java) with a VERY LENIENT LANGUAGE (PHP). So its safer to be on the same language.
Tutorials:
Official tutorials to get started: http://restlet.com/learn/tutorial/2.2/
Good step by step tutorial with screenshots and code snippets: http://java.dzone.com/articles/restlet-framework-hello-world
Short:
Take JAVA!
Always choose the language you are comfortable with. Also I think Java is better suited in the end.
PHP isn't my favorit. Most of the people like it, because it is easy to start with. (It was also for me the second (non Browser) language I touched.)
Framework Tips
WebFrontend: Play Framework
Back End&Scaleability: AKKA
JSON: Gson
Long:
Scaleability in the meaning to scale to lots of concurrent users:,
is more a architectonical issue, as a question for the right language. You can write scaleable software in any language. The difference isn't the scaleability of a language, but it could be the performance. One language will take longer for the same task as the other one. But you could always throw more Servers in, to scale out.
Architectures to consider if you want to scale out, are in my opinion message based designs. My favorite is the actor model, there is a very good framework for that in Java, the akka framework (production proved). But I think you first should get your software running. If you get enough users... scalability problems are the problems you like to have (they mean you have users).
Scaleable doesn't only mean, that you can scale to many concurrent users. But the ability, to handle the complexity of the software or can handle concurrent development and so on (your team will grow, thats also a problem to handle). In this topics Java is as clearly static typed OOP language, better suited.
Also the performance will not be as good as in Java (it is a interpreted language). But there are always options. Facebook started with PHP. In an interview one of the lead developers, told that PHP isn't that scaleable, because PHP wasn't designed for OOP. But the performance issue was handled, through writing a compiler for PHP (outputs C++). [If if find the link I will post it] .
Update the PHP Compiler is Called HipHop and it uses HHVM (Hiphop virtual machine), Facebook developed it after excessive CPU usage
You can consider looking at https://jersey.java.net/ As a web container you can use anything like Tomcat. I have used Google App Engine in the past.
To get started quickly with Java look into http://dropwizard.io/, using less EE frameworks and more standard Java.
Has Jersey for REST and is supereasy to run.

PHP-Dojo vs Java for large application [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
My company is in the infant stages of looking to building a team to develop a new platform to replace our existing system. UI/UX is extremely important since there are several thousand users. The current system is built in PHP with Zend.
I have been doing a lot of research and have thought about Yii with DoJo or something similar. I have also looked at the ZK framework if we decided to go the Java route. Whatever we choose the framework has to talk well with linux and be able to perform low level system operations like creating/updating files, etc.
At the end of the day I know very little about Java but the more I look it seems like all of the clean web applications are running Java.
Am I missing something here or am I on the right track thinking:
PHP = easier to train and hire people. Harder to get a rich UI
Java = harder to train and find developers. Clean UI more easily obtainable.
Choosing Java over PHP isn't much about a clean UI, is much more about the ability to grow in both size and complexity.
Don't get me wrong, I'm aware that there's a lot of big complex systems running fine with PHP, it's only that I find that Java has more support built in the platform for scalability.
You can have a clean, rich UI with both PHP and Java.
PHP - Easier and faster to get started. Harder to get around performance and scalability issues, even with proper knowledge.
Java - Harder to "get it right". If everything is done properly you'll reach performance problems later than with PHP... but with the proper knowledge it will be easier to find solutions.
But, as far as UX goes, you should go with what your developers are most confortable with. If the UX and backend logic are decoupled you can treat them as separated problems.

Categories