Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - Executable JAR? Easy Decompiling? [closed]

Tags:

java

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.

  1. 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?

  2. 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?

  3. 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.

like image 836
user2081339 Avatar asked Jul 19 '13 20:07

user2081339


3 Answers

  1. 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

  2. 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.

  3. 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.

like image 115
Jesper Avatar answered Oct 08 '22 12:10

Jesper


  1. That is an option. It's certainly not mandatory, you can load resources from external files as well.

  2. 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.

  3. 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.

like image 2
Affe Avatar answered Oct 08 '22 13:10

Affe


  1. Yes, you can put everything in one jar
  2. 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.
  3. 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.
like image 2
Mariusz Jamro Avatar answered Oct 08 '22 12:10

Mariusz Jamro