Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Is it possible? Runtime Questions

  1. #1
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    Location
    San Pedro Sula, Honduras
    Posts
    58
    My Mood
    Inspired
    Thanks
    11
    Thanked 1 Time in 1 Post

    Lightbulb Is it possible? Runtime Questions

    Hey guys,

    I am still not a pro with Java but my imagination isn't bad at all. I know with Java I could "be God" and do whatever I want, just that I need to learn to be able to get there. Even so, I still would like to ask you fellas a couple of questions, and probably get a hint or two on how to get to what I am trying to accomplish.

    You know, the JVM jumps from class to class when we let it know she need to look for the code elsewhere. I've been working on a project of main classes creating other main classes. The good thing about them is that they are independent from from another if I make sure its that way.

    1) Is it possible for the runtime to jump from one program to the other, without ever having to go back to the original main class?
    In other words, I am asking if there is some sort of "break" operator, that enables the runtime to completely divorce from the original, stopping without ever going to the last part of the code of first main class.

    2) Is it possible to have 2 or more runtimes, which originated from one Runtime?
    We are still talking about independent classes creating and starting other classes.

    3) If question #2 is a "Yes", how many Runtimes could the JVM or equipment would be able to handle?
    For example, how many 10kb - sized main classes could run simultaneously, without having the JVM ask for mercy, or the rest of the equipment.

    4) Classes are compiled in the native byte code. Is it possible to convert class files into a different programming language?
    This is a logic question, since we know that byte code is the native language, some kind of "international" convention or converging point to other languages.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Is it possible? Runtime Questions

    1. Classes aren't executed, functions/methods and statements are executed. You can pop up multiple frames on the call stack by using exceptions, but the preferred method is to introduce logic in the calling code which will return normally. There are a few other minor special cases, but these should be avoided whenever possible. There is no goto statement in Java (despite there being a goto keyword in Java, there are historical reasons for this).

    2. Each runtime is a separate process execution. In general an application isn't multi-process, rather they are multi-thread. This has multiple paths of execution which can run concurrently on a single process/runtime.

    3. You can have as many processes as your system/OS allows.

    4. Java byte-code is not assembly/machine code. That's both a benefit and disadvantage of Java byte-code. The process of converting a lower-level output code to a higher-level format is de-compiling. Java byte-code preserves (or can preserve) a surprising amount of information, so it's relatively easy to de-compile Java byte code back to Java. Note that even if you de-compile back to Java, you're not guaranteed to get back your original source because comments will be lost. I'm unsure what level of optimization different Java compilers use to get to byte-code, but if any optimizations are done you can get some really different output, with the only guarantee that the output be that the output will have no noticeably different results.

    De-compiling Java byte-code, or even just converting Java code to another language may be possible, but I have my doubts. The main problem is the Java standard library, which may have no direct equivalent in another language. Basically, good luck getting this working for the vast majority of programs.

  3. #3
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    Location
    San Pedro Sula, Honduras
    Posts
    58
    My Mood
    Inspired
    Thanks
    11
    Thanked 1 Time in 1 Post

    Default Re: Is it possible? Runtime Questions

    Hey great answers overall.

    I am just not to happy with your first answer -that was straight from the book. Probably I did't get my objective clear with these questions.
    I know about calling code. And Yes we can technically call cmd prompt to complie and execute another main class. I am certainly interested in these "minor special cases" because the whole idea of executing class files technically not dependent of the original one has a purpose to it.

    Is there anything you like to hint me? I would appreaciate.

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Is it possible? Runtime Questions

    You can't "jump" into another process. The closest you get is start another process and forcibly terminate your current process. I have no idea why you would want to forcibly terminate your current process just because you started another process, though. Your process shouldn't terminate suddenly unless something horribly wrong has happened.

    What are you trying to do? There may be a better way to accomplish the same goal without using some very unsafe code.

Similar Threads

  1. Runtime Error
    By Dennis Enya in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 24th, 2013, 12:44 PM
  2. List of my Java3D Questions, and Proguard questions
    By Zachary1234 in forum Java SE APIs
    Replies: 0
    Last Post: November 16th, 2012, 08:40 PM
  3. Runtime.Exec() not waiting
    By PrinceSendai in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: June 9th, 2011, 02:12 PM
  4. In eclipse how do you get the runtime of your program?
    By beginnerprogrammer in forum Java Theory & Questions
    Replies: 5
    Last Post: May 22nd, 2011, 03:19 PM
  5. Runtime Error
    By SyntheticD in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 10th, 2011, 03:09 PM