Running a Java executable class from another executable class
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Running a Java executable class from another executable class
I am programming with Java and have 2 executable classes, win.class and programManager.class. Both have main() methods and are executable. I want to execute programManager.class from win.class. Can this be done, and if so, what command would I use to do it in my win.java file? All .java and .class files are in the same directory.
hello LUB997 ...
i just wanted to ask if u know what is Object-Oriented Programming ??
i don't realy know what your program supposed to do , but u could change your design and insted of using the static main method , u just could create object of that specific class and send it messeges so that it will respond the way u like ... .. .((( modularity is important thing for programmer )))
modularity is : ---->>
A quality of a system where it consists of various parts which separate cleanly and fit together well. High modularity costs some design time but pays back well through clarity, elegance, maintainability and -->> FLEXIBILITY <<-- .
I got it to work a different way. I finally figured out how to apply the example in my Java book to my own program and ended up using a package. I just put "package win.manager" at the top of my source file for programManager.java and then on win.java did "import win.manager" and then to call my programManager method from my programManager.class stored in win.manager I just did "programManager();" in my win.java source file. Worked beautifully, but it took me a while to figure out since I don't know a whole lot about Java or object oriented programming yet. I've taken a year of C# in school, but we still haven't really gotten into the object oriented aspects of it yet. For those wondering what kind of program I am making, I am making a Windows for Workgroups 3.11 clone in Java. Not for any particular purpose, but mainly just for the sake of doing something complicated to advance my programming skills, but not so complicated that I can't do it. It of course will not be able to run Windows 3.1 programs, but will just be the Windows 3.1 GUI. win.java is my main screen (the background), and programManager.java is just that; the program manager. As anybody who remembers the DOS days recalls, you used to type "win" from the command prompt to start Windows 3.1. With mine you type "java win" from the bash prompt. If anybody's interested in it, I'll gladly share the sourcecode on it when it's finished, but not until then because the idea here is for me to learn something after all, and not just have others do it for me. Once I succeed at creating it in Java I will then try something more complicated and Linux oriented such as C and maybe GTK or QT for the graphics. My real goal is to create Linux programs, and thus I am really more interested in C than Java, but in this case I chose Java because you can do a lot with it fairly easily, and this is my first run with a program that has a detailed GUI, so I didn't want to use a language that would complicate things too much for me. Thanks for all the responses!
win.java:3: illegal start of type
... <<------------------- what such a fool error , :-o :- ( :- o :~ o :~|
win.java:7: <identifier> expected
2 errors <<------------ not realy two errors , the second is a result of the first ... .. . lol
ofcourse it will not compile since u repeat the same errors from that piece of code , there is nothing called ( ... ) in java so you should replace it with java type like ( ArrayList , AvlTree , Graph , .... ) or a type that u made in the same folder or in an imported package . ( i realy wonder how u make such an errors ???!!! )
an other thing , there is nothing for this to do with object oriented programming ,
Hmm, do you really know object oriented programming ???
yes i do ... in OOP course i get 95 last semester ... .. . :-)
I used an ellipsis (three dots) in my sample code to represent parts unrelated with the demonstration,"programManager.main(args);" can be used from anywhere inside the win class.
the underlined is not true , since u can't use it from any where inside the win class ( exactly the same error which u made in that piece of code ) it should be used from a body of one or more of the win class methods including the main method ,
I was hoping you take my previous posting with humour, but am disappointed and sorry you missed it ...
well , no ...you shouldn't be niether sorry nor disappointed cause i didn't miss it , further more i wish u didn't and will not miss the humour in mine ...
Can you state the purpose of the program and what it will be doing. In Software Engineering/and Hardware Engineering, we are taught that design is the most important step to coding/or simulations. A universal truth. Please let me know and you *may* rework the design if needed.
If you are invoking main within a main, it may be time to look at design, as that is not a very common case (never seen a need for that one in all my years programming, but there *could* be, I guess. This all depends on the design).