I have few queries regarding compiling v/s execution of a java program. Suppose I have a Main Class which is referring to class Test which is present in JarA. Now, at compile time, this jar JarA must be present in classpath/buildpath. So, what actually is the action performed by the compiler by referring to this jar?
Now, at runtime also, this jar should be present to execute the Main class. Is this correct? If yes, then what is the action performed by JRE when it refers to this class at runtime? WOn't all the dependencies be resolved at compile time only?
public class ComparativoV3{ public void loadComparative(String path){ } public void compareDbs(){
[Code].....
how to set it up the private void CompareActionPerformed(java.awt.event.ActionEvent evt) as the ComparativeV3 main class, not giving it any argument, because the files are load from the arguments section & it reads diferent files with diferent arguments.
I am having hard time to grasp the concept of java as i am beginner. according to different sources found in internet, only one class is written in one source file. and all those class can be accessed through the main class. my question is
1.can we access one class present in one source file, through another class present in another source file [not through the class containing main method]?
2.can we create more than 1 class in same source file?is there special way to do it? i do get error always when i try to do so 3.can multiple classes contain main method? or should there be only single class containing it?
My java class doesn't execute a shell sript, I had given the java io file permission read and execute over the script shell to the user who execute the java class, also I executed the script shell in the console each RAC server using oracle user session and the srcript shell works. My team DBA told me that " The user server process is oracle". My script shell resides in all RAC server file system the last result looks as follows:
/home/mydir/dir2/mybin/compacta_archivo.sh No Funcionando!! java.io.IOException: /home/gi91591/reppostpago/bin/compacta_archivo.sh not found
[Code]....
of course, the script file exist on my file system, it has the suitable permission as the test result i got each time I executed on the console. My Oracle version is 11.2.0.3.0 on Rac ASM.
public class Sphere { public double diameter; public double volume; public double area; public double fourThirds = 4/3; public Sphere(double someDiameter){ someDiameter = diameter;
[Code] ....
I am trying to get this code so that I only enter the diameter once in the sphere object1 = new Sphere(4); but I can't get it to work right. I can get the diameter to work with the calculate volume and area methods but that's it.
Im writing a simple program to understand classes and objects. Basically what I have is a file called Program.java where I have my main method.I have another file called Person.java which I want to use to create Person objects. That person can have a name, email adress, phone number, etc.I put both these files in the same folder.in Program.java my first statement is:
My problem is that when I compile Program.java i get an error message saying that the package Person.java does not exist.So my question is, when you create a class that you want to use for objects, how do you import that class into your class with the main method so that you can use instances of your other class?
// Add range to Vehicle. class Vehicle { int passengers; // number of passengers int fuelcap; // fuel capacity in gallons int mpg; // fuel consumption in miles per gallon
// Display the range. void range() { System.out.println("Range is " + fuelcap * mpg);
[Code] ....
I'm compiling it in Eclipse and this continues to show in the console display
Minivan can carry 7. Exception in thread "main" java.lang.NoSuchMethodError: Vehicle.range()V at AddMeth.main(AddMeth.java:34)
Need to use a ComboBox from another class (Beginning Java forum at JavaRanch)
When my file is saved it has the values off the main gui's comboBox in variable 'env' which I then write to file using. I just need to access the comboBox in my second class so I can use it in main as I'm using the wrong one atm- if that makes sense?
I have a program with 4 classes, all of them in the same package, one of them is the Main class, and in that class I declared a variable named "port" of type int. One of the 3 another ones is the class Connection class, which it requires the port variable. I want to use this variable in the Connection class. How can I do it?Both classes are shown below:
Main.java package server; /* Imports */ /* Another variables */ int port; /* <-- IS THIS ONE */
import java.io.FileNotFoundException; public class PrimaClasse { public static void main(String[] args) throws FileNotFoundException { SecondaClasse oggettoSeconda = new SecondaClasse(); oggettoSeconda.controlloNomi();
[code]....
Now it's working and from the main class i can controll the second class BUT. i want that is the main class that ask the user name, and i want pass that value to the second class. what code i must change?why eclipse wants me insert this import java.io.FileNotFoundException; and this throws FileNotFoundException for not give me an error?
I want to hyphenate a token which is present in a database. My code:
String str = "The Appointments Committee Cabinet has approved the appointment of Dr. Harry Potter, Chief Economic Adviser, Department of Economic Affairs as Executive Director in the International Monetary Fund."; String[] words = str.split(" "); LinkedList<String> linkedlist=new LinkedList<String>(); for (int i = 0; i <= words.length-1; i++) { linkedlist.add(words[i]);
[Code] ....
I want to implement this algorithm, I will start with "The Appointments", whether it is present in table or not. If yes, then move forward and check for the next token- whether entry for "The Appointments Committee" is present. If yes, then again move forward, and check for "The Appointments Committee Cabinet". If entry is present, then again move forward, if not, then move back, then hyphenate "The-Appointments-Committee". Then again start with "Cabinet"- the same process all over again. I want to use a select query- it should give a smaller result set, so the speed should be much faster.
In summary, the Class XCopy's Main method creates an instance of the XCopy Class. So, now knowing that this can and does occur my next questions to myself were:
When would I do this? How can this best be used?
Is this just another option available to a Java developer that has no other special significance?So far have no answers for myself.
I've written a program just for the sake of it (to learn) and it seem's like theres quite a lot in the main method that perhaps could be split up into seperate classes. I'm not too sure where should start with this though, or what my thought process should have been as I was writing the program.
import java.util.Scanner; public class Loops { public static void main(String[] args) { int answer = 16; Scanner scan = new Scanner(System.in); // Question System.out.println("What is 4 x 4 ?");
[code]...
--- Update ---
here's a version without code comments as they might make it harder to read here -
import java.util.Scanner; public class Loops { public static void main(String[] args) { int answer = 16; Scanner scan = new Scanner(System.in); System.out.println("What is 4 x 4 ?"); int userAnswerInt = 0;
I have permanently set the path of bin of JDK 1.6 in the environment variables of my system. I am able to compile any of my java programs successfully. But when I give command to run the program I am getting an error "could not find or load main class".
When I write the command "set classpath=.;" program runs successfully. I want to know whether I have to set this classpath everytime I run a new progaram. Is there any permanent way to set classpath ?
I creates this simple code (shown below) inside a package of a major opensource code (i.e., openSHA), but when i run it the following error appears. The error mentions a class named "KT_testGmpeForScenarioRupture" that i wrote before and did not run showing exactly the same error.
Code:
package org.opensha.sha.gcim.imr.attenRelImpl; public class KT_Test { private static void main(String args) { int x=4; System.out.println("x is " + x); } }
Error: Could not find or load main class org.opensha.sha.gcim.imr.attenRelImpl.KT_testGmpeF orScenarioRupture
This time I have to make a Black Jack game ( I guess this is a classic) I have created Three classes for this BlackJack( Main), Card, and Player.
What I am trying to do is put the Give one card to the player and remove it from the deck into a separate procedure because I will be doing this several times during the game.
This is the code I have so far Under the class BlackJack.
I am using Netbeans as my IDE and I have created a program called Saluton.java
I navigate to the folder holding the class file using the command line under Windows 7 but when I issue the command java Saluton.class I get an error it cannot load or find the main class.
What is the main advantage of nested class? Rather making one class reside inside other, can't we achieve all by making it two separate classes with its own individuality?
I made a breakout like game that runs as a applet and now i wanted to make it run in a jframe so i wrote this
Java Code:
import java.applet.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; public class BrickBuster{ public static void main(String[] args){ JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); JApplet BrickBuster = new JApplet(); frame.add(BrickBuster); BrickBuster.init(); } } mh_sh_highlight_all('java');
It compiles fine but whenever i try running it with the java command it says it couldnt find or load main class. also i have it save in a folder called BrickBuster so i called java BrickBusterBrickBuster.class