when you write an app in java, people need to have this java installed to use it right?
Sorry if this is a dumb question.
Traroth is correct; your audience needs the Java Runtime in order to use your java.
However, they don't necessarily need that Java, or in other words, they don't need to be using Sun (now Oracle)'s JRE. They could also be using the OpenJDK, or any of the other free java implementations.
Not a silly question at all.
Side Note: As Glenn Nelson stated, there are Ahead-Of-Time compilers, and if you want to go down that route, go ahead. But I'd strongly warn against jumping into that boat, especially if you are just starting off in Java. AOT Java compilers come with their own set of issues.
Yes, you need the Java Runtime to run a java program:
http://java.com/en/download/
There are also executable installers which may bundle Java or download it during the installation. You may also use "Java Web Start".
Related
Nowadays, I've started hearing a lot about Java. I know that its because its meant to be cross platform. But is it really?
How much can we trust the client to have JVM installed? I've quite a few books on Java in my home and really wish to read them. But every time the same question strikes me. Will the apps which I develop with Java run on most of the machines? Isn't that bad?
One way out is to use some compilers to compile Java code to native machine code. But this makes me feel, "Why use Java then?"
So, Is it worth to learn Java for cross platform? Any ideas regarding the percentage of people having JVM installed?
I would like to correct you, People dont require jre installed they require jvm.
Since Java only relies on JVM, it is platform independent (if the platform has JVM installed).
But the main thing is, That the programmer do not have to know specific knowledge of the Platform and program his application keeping one specific platform in mind. He just has to write code generate byteCode and rest part is handled by JVM, to run it on any other platform.
If you compare java with other language you will get the exact difference like in In c/c++ the source code(c program file) after the compilation using a compiler is directly converted to native machine code(which is understandable to particular machine on which u compiling the code). And hence the compiled code of c/c++ can not run on different OS.
Nowadays, I've started hearing a lot about Java. I know that its because its meant to be cross platform. But is it really?
Yes, Java is cross-platform - or, more accurately, portable. It runs on the most used architectures and platforms, often without modification, which makes it one of the most portable languages out there. (But keep in mind that you can write unportable code in almost any language and Java is no exception.)
How much can we trust the client to have JRE installed?
We can't, but that's almost never problem.
Most languages need runtimes in order to operate. The C language (and some of its derivatives, like C++) get away with the fact that the C runtime is often already installed in the OS.
For most other languages, we trust the end user to be at least willing (not even necessarily able) to install the required runtime in order to run our (and others') software. Most software these days (and this often includes C++ software) installs its required dependencies automatically in the installation script. If this isn't desirable for any reason, an alternative is to bundle (statically link) the runtime with the program when deploying it.
One way out is to use some compilers to compile Java code to native machine code. But this makes me feel, "Why use Java then?"
Not all languages that compile to native code are the same. They have different features, different tools, different libraries available, and so on.
In any case, make sure you're not confusing native compilation with static linking of any dependencies (runtime or libraries).
Even, tell me how much percent people have a JRE installed.
About 97% of enterprise computers and 89% of desktops in the USA are estimated to run Java.
The client needs a JVM, not a JRE. They will run on almost all machines. I don't have a percentage but considering that pretty much every major OS has a JVM available to them, I would say around 95% (underestimation in my opinion). Java definitely does not have a limited audience so that shouldn't stop you from using Java.
Updated in light of Andreas' comment. I was under the impression that a lot of machines came pre-installed with Java. However, the JVM can be easily downloaded so you still don't have to worry too much about whether you're going to miss out on a large audience.
I think you mixed two different concepts:
Cross-platform: A program is considered to be cross-platform if it can run on different platforms without a need to recompile it.
Q: Is Java cross-platform?
A: Of course it is.
Native app: A program that runs on the targeted platform without a need to install, download any other software. Usually the program is compiled into a machine binary. However, it may in some definitions include programs/scripts that are not machine binaries, but the target it platform is guaranteed to run them with its built-in library/software.
Q: Can Java run on any platform without JVM?
A: No. JVM is not shipped with any platform that I'm aware of, so it needs to be downloaded and installed before any Java program can run.
One way out is to use some compilers to compile Java code to native machine code. But this makes me feel, "Why use Java then?"
It all depends on what you want to achieve. If you want to create native apps, drivers, etc, then Java is definitely the wrong tool. But if you want to create an app that can run on all platform without having to recompile it and create a version for each platform, then Java can be a good option.
So, Is it worth to learn Java for cross platform? Any ideas regarding the percentage of people having JVM installed?
Again, it really depends on what you want to achieve. Java is a good option for creating cross-platform apps and it is worth learning. However, there are other options that you may want to look into, compare, and decide which one to learn. C# is a great language, and just recently, Microsoft announced its plans to make it truly cross-platform, so it is another good option.
Most PCs have JVM installed. Theodoros Chatzigiannakis provided some statistics in his answer. But you shouldn't be too worried about the numbers. Those few who don't have JVM installed, will be willing to download and install it if they like your app.
Note: In the past, you could run apps written in C# on platforms other than Windows, but you needed a .Net Framework equivalent (e.g. Mono). With Microsoft recent announcement, we should be able to use Microsoft .Net Framework itself on other platforms. We will see how this will turn out.
I want to learn the internals of JVM. For this purpose I chose Jikes RVM to work with, but the problem is that I am not able to debug the source code as it doesn't support it.
My question is that is there some open source JVM which can be debugged to see how it works with class files. I am in real need of some good information about it.
Thanks
Well, since the Oracle JDK is open source, this might be a good place to start: http://openjdk.java.net/
The internals of the JVM is different between JVM's and knowledge gained from one may not be usable for other JVM's.
If you want to see how the runtime library (all the java.* classes) is implemented, there is a src.zip in most JDK distributions (not the JRE ones). If you use Eclipse, set it up to use that JDK as the JRE and you can navigate directly around in the various classes starting from your own program.
Sorry for the stupid question, I'm just beginning to learn Java. Can it be compiled into a .exe to be run on another computer, or is it only for computers with a JVM?
Not exactly. You can bundle a JRE with your executable, which is kind of like the same thing. Embedding a JRE is one approach offered by launch4j.
There are third party projects that will allow you to do this. A free one is http://gcc.gnu.org/java/ . I don't believe it's officially supported by Java though, but it's also gnu, who happen to know a thing or two about compilers.
There is also http://www.excelsior-usa.com/jet.html which is a paid product, but supports up to Java 6.
Can you make candy without sugar?
Yes, you need to have a JVM (just the executing for compiling) to run and to compile.
Although, it is not necessary when trying to write just the code.
I was looking for a Desktop Application Programming Language with one of the biggest constraint: - “I need to output as native executable”.
I explored multiple options:
Java is not a very good option for desktop programming, but still you can use it. But Java to Exe is a problem. Only GCJ and Excelsior-Jet provides this.
.Net platform does not support native compilation. Only very few expensive tools are available which can do the job.
Python is not an option for native compilation. Right?
VB6 is the option I am left with.
From the above list, if I am correct, VB6 is the only and probably the best option I have.
But VB6 itself has issues like:
It is no more under development since
There are questions on support of VB6 IDE with Vista
Thus my questions are:
From the list of programming language options, do you want to add any more?
If VB6 is good/best option, looking at its development status, would you suggest using VB6 in this era?
Delphi (and its underlying Pascal language) is still alive and well, with the 2010 edition recently released; if you have funding (a minimum of $899 for the cheapest edition, I believe). it may be worth your time to download a try a free-for-30-days (or something like that) version.
Out of curiosity, what are the driving factors behind the "native-binary-only" constraint?
As others have said, it's essentially impossible to prevent reverse engineering. (I realize the answer I linked to is in the context of .Net, but it applies to all programs.)
You added a comment saying it is because .NET and java can be decompiled that you don't want to use them. You could use an obfuscator which makes the output code harder to read.
Visual C++ is an option, though unfortunately the free version is a bit crippled from the point of view of building MFC-based applications.
You can also choose to use a different GUI framework than MFC, such as wxWidgets or Qt. With these frameworks a GCC compiler (such as MinGW) can be used. There are several free IDEs that are supposed to work with one or both of those frames works including Qt Creator or Code::Blocks.
I've heard good things about Delphi, but don't know anything else about it.
I was involved in a hunt for a similar language/platform for a client to replace their VB6 application. Although they eventually decided to webify everything and rewrite it all in Flex, they were briefly looking at RealBasic. VB6-esque syntax and it compiles to native binaries.
I can't speak for what it's like for day to day use; the trial looked ok. A bit of the RAD oh-that-didn't-take-long workflow that VB6 had and very little else has got anywhere near. Not unreasonably expensive for the Personal Edition.
Check out 'Power Basic' - It compiles 'true' small native EXEs and provides a fast VB like basic environment, and doesn't require a run-time environment. This makes it much harder to disassemble. It isn't VB, but its affordable and powerful.
VB is an interpreted language not native although I guess there are native compilers. Also it's runtime support is not guaranteed past windows 7. The IDE and runtime have a few issues in windows vista and 7 mainly related to UAC and network drives.
I would suggest delphi or some c variant if it must be native.
I've been charged with creating a little GUI launcher app to go on a CD which will offer the user some software and some videos. It's not being aimed at particularly tech-savvy people, so it needs to be quite simple. I guess the real sticking point here is that it will be form based.
I would very much like the launcher to just run from an exe without having to install any .net stuff or have java installed. I know ClickOnce is fairly simple and I will fall back on it if necessary, but I thought it might be worth asking if there are any easy ways to do this.
I mainly program using visual c# these days, but have experience with java and c and I am a relatively quick learner, so feel free to suggest other languages.
The most straightforward way to create a dependency-free executable for Windows is to use ordinary Win32 functions from C (or C++). Alternatively, you could use MFC with C++ because you can link MFC right into your executable to avoid a dependency on MFC DLLs.
There are probably other C/C++ frameworks that can be linked into an executable. However, you probably want to avoid Java and C# or any other .Net language, if you want minimal dependencies.
Depending on the minimum target OS, you could possibly choose VB6, if it doesn't affend you too much, because the VB6 runtime has been included in windows since Windows 2000. However, you need to stick to the included controls to keep things simple.
If you write it in Java you could bundle the JRE on the CD and just have a batch file that uses that bundled JRE to launch the app. This should work, but the JRE is kind of large, so you'd need to make sure you'll have enough space on the CD for it.
.Net might be able to do something similar but I've never looked into it at all.
The simplest thing would probably be to just write a simple native app in C/C++ (or in some other language that compiles to a standalone EXE) and use that.
Just statically link to the C runtime library and any others you might need (like MFC): /MT or /MTd on the command line and Project Properties > C/C++ > Code Generation > Runtime Libraries in Visual Studio.
You can use C++ with wxwidgets for GUI and statically link your application
Now all the windows OS (from win 2003) pre installed with .Net frameworks... so you can go ahead and code in any CLR language...
You are saying ur clienats are not tech ppl, so the chances for uninstalling .net frameworks from their machine is very low..