New code on old JVM [closed] - java

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
I have class corresponding with Java 1.5 and later. It's compiled in Java 1.7.
And now turns out that I have to launch it on Java 1.3.
How to solve that problem?

if you have the source files iwould just try to compile it in the version you need. if this won't work you need to "get rid of" unsupported stuff (e.g. generics)
if you don't have the source-files, i would trying to decompile it and compile it in the version you need.
Stackoverflow Answer on decompiling

You code in 1.5 and you compiled in Java 1.7(Java 7). if you want to run this one in to Java 1.3 then you need to sure about API what you used in code. The API what is used in code it should support in Java 1.3.
Example:-
Lets have a example. if you use generics in you code. but as we know java 1.3 not support generics. so this code not going to work on Java 1.3. you need to remove and look for alternative.

There are a few things to consider:
Class format (you can set the target class format to 1.3 even with 1.7 compiler)
API changes
Must not use generics

Ok, I solved it that way (quite primitive):
I compiled it using javac, then I opened it in Hex Editor, eight byte changed on 2F, saved and it works!

Related

Download Java using Java [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 4 years ago.
Improve this question
I have an application that's built in Java 10. Most users only have Java 8, so they would need to download Java 10 in order to use the application.
Would it be possible to make a launcher that could download Java 10 for them so they wouldn't need to think about that?
Since Java 9, there is a new tool named jlink that you can use to create a custom Java runtime environment with exactly the parts (modules) that your program needs. You could use this for your program, so that your users don't need to have a pre-installed Java runtime environment at all - you would give them the custom runtime environment included with your game.
Another possibility is to try to compile your program using JDK 8 - you can still download JDK 8 from Oracle. Depending on how you wrote your program, you might need to change a few things in your code to make it compile and run on Java 8.
You can distribute your app with JRE (i.e. that's what JetBrains do with their IDE's).
Official Java documentation about this solution:
https://docs.oracle.com/javase/10/deploy/self-contained-application-packaging.htm

Migration of Java Application from 1.5 to 1.8 [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 4 years ago.
Improve this question
We are working in the project of migrating a application(built in java 5)
to java 8 for better performance,
But , we are not sure that
1. upgrade an environment or
2.Build that complete app in java 8 from scratch,
and how it will improve the performance !
And we know that, There will be some Deprecated API's from version to version.
so, while upgrading is it possible to get error or miss some functionality ?
How can We rectify that?
Please comment your suggestions !
Java has full backward compatability, So
If you just change java version then it will not have any errors as java8 is fully compatible with previous java versions.
If you want to improve performance using java8, Then you have to read java8 release notes to know where you can get faster alternative of current code and then you can only re-wright that functionality only
firstly you can always migrate to newer version of java as java is backward compatible. Also, you are right, few API's might have been deprecated but you always have the new options of those which can be solved.
My suggestion would be, if you don't have huge code or a bulky API, re-write the same in new version as u might utilize benefits of functional programming.

Is it safe to compile againts later JDK? [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 6 years ago.
Improve this question
I have some big projects running on Java 6. But I plan to start building them in Java 8 since a lot of build tools have moved away from Java 6.
Is it safe for me to simply compile them with Java 8 and then deploy them in a web container running Java 8? If not, what are the considerations?
FYI, they don't have a proper automated test suite in place.
The problems can be related to:
deprecated methods that are removed in java 8 and you used in the old java 6 code
different behaviour for some methods:
There are aspects of the platform's behavior that are intentionally unspecified and the underlying implementation may change in a platform release.
configuration of web container that can be different from a version supporting java 6 and the version supporting java 8
external libraries that changed during the passage from java 6 to java 8 removing old methods so that your code can't compile
So yes it is possible that the passage from java 6 to java 8 can broke your code.
But if the code compile it is quite sure that the behaviour of the code is the same, because generally (but not always) a retro compatibility is granted. You can be sure of that only running a complete set of unit tests both on java 6 and java 8 versions.
Here some example of not compatibility between java 6 and java 7:
JDK-6527962 : Retire the non-standard package com.sun.image.codec.jpeg. If your code use this package the it doesn't compile on java 8
JDK-6563734 : Path2D.Float and Path2D.Double should have final getPathIterator methods If your code ovewrite the methods declared final the code will not compile passing to java 8
Here a complete official list of incompatibilities between java 6 and java 7
Here a complete official list of incompatibilities between java 7 and java 8
It usually should be, since most of the features are backward compatible. However, there are no guarantees. Please do follow the proper process and do testing before rolling out to production.
For web container , with jdk, version would also have changed. This may cause some problems depending upon the software vendor and what all services you are using from the container ( JNDI, connection pooling etc).I once had a problem in migrating application to higher version of JDK. We also upgraded Websphere. We were using JSF, and higher version of WAS had JSF jars included, which was clashing with our application jars.
Your apps may be using a lot of 3rd party library which may be impacted. Again, mostly you should be Ok, but there can be small issues. Without knowing your applications, I can only suggest migrate and test to confirm.
You need to test things very thoroughly. If there are bugs, then it is imperative to find them and fix them before you move on to the next version. If you have a sunny day scenario and do not have bugs coming from the upgrade, then at least you know that for sure after the testing.
However, you need to know what to focus on. You need to read about changes applied on version 7 and on version 8.

How are commands and their functions defined in Java? [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 6 years ago.
Improve this question
Does Java use libraries to determine which commands perform specific actions?
After learning Java for a few weeks now I don't really understand how Java recognises which commands perform specific functions in code.
For example, how does Java know what to do when you use a "do while" loop? And how does Java remember so many different commands, is there some sort of master list or a combination of libraries that document recognised Java commands and their functions?
This may seem like a real noob question, but it's been bugging me for a while and is getting in the way of my understanding of how code, and specifically Java works. Thank you all in advance.
Edit: Just to make this more specific, I was confused because I didn't know how new functionality is added. So, as I understand, new commands and functionality is added to Java using additional packages alongside the JDK, which contains a list of the most fundamental Java commands?
The commands and the full syntax of the language is defined in the Java Language Specification. The Java compiler generates low level instructions (i.e. bytecode) according to that syntax for language constructs like the do-while loop. The JVM is then responsible for executing those bytecodes.
I understood your questions in two ways:
1 - Where does java hold its lots of functions, classes, etc.
2 - How does java work (how does an if/else work) under the code's skin.
First, there is no noob questions, we are all here to learn :)
Second, about the questions:
1 - Java holds its classes in the Java Development Kit (JDK). Because of this, when you create a Java application, you need it installed in your machine, so Java will find a lot of its classes in the installed JDK.
You can expand the amount of classes by adding new packages (jars) to your project. Then, Java will see all the JDK classes and your added jars.
2 - If you mean to "how does java work in a do-while loop or something related, you want to learn about javac, java's compiler.
Javac will get your code and transform into an jar file. The Java Virtual Machine interprets the compiled code to do memory operations.
For exanple, when you assign a variable to java, internally you create a space in memory with the datatype's size.
When you do a while loop, the JVM will use other VM functions to do the job.
That's actually a quite advanced question. I think you can find more about what you want here.
Hope it helps! :)

plugin java version and project java version [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
I am writing an eclipse plugin, compatible to java 1.5.
If anybody who is working with java 1.5 or lower or higher, installs this plugin, will it work well?
You should included a Bundle-RequiredExecutionEnvironment: J2SE-1.5 statement in your plugin MANIFEST.MF if you are targetting java 1.5. That is both documentation and a note to the OSGi runtime about what is valid within that bundle.
No. It won't work on lower versions if you are using java 1.5 specific library calls which are not available in lower versions.
It depends on what functions your plugin uses. Certain functions are eventually marked as deprecated and are dropped in future releases, this can cause issues when newer versions of Java will run your code.
On the other hand, new functions tend to be added from one version to the next, so in your case, older versions might crash since some functions your application uses simply do not exist.
At most, what you can do is to specify a minimum Java version, and eventually even this can cause problems.

Categories

Resources