my java is broken !

B

bilsch

I wrote a loop to read a 26000 character text file NVRAM.TXT into a
character array. It worked fine. The program is listed below. It has
only 24 lines. Today when I run it, it has weird errors referenced to
line numbers 2442, 2685 and 1620. When I click on those error messages
it shows lines in a completely different program - a program that I
never wrote for sure. I saved the file with a different name and it runs
fine with that name - no errors. The file name that has the problem is
Nvj5. That is the file selected and displayed when I click RUN FILE. It
is the file listed below. Even though it is selected and displayed when
I click RUN FILE my system is running some other huge file instead. Has
anyone ever heard of a problem like this?

import java.io.*;

public class Nvj5 {

public static void main(String[] args){

try {
FileInputStream file = new FileInputStream("NVRAM.TXT");
char[] nvchr = new char [30000];
int fin = 1;
int count = 1;
while (fin != -1) {
fin = file.read();
nvchr[count] = (char) fin;
System.out.print(nvchr[count]);
count++;
}
System.out.println("Bytes read : " + count);
file.close();
} catch (IOException e){
System.out.println("Could not read file");
}

}
}
 
S

Stefan Ram

bilsch said:
I click RUN FILE my system is running some other huge file instead.

Possibly, an exception was thrown from the standard library and
the line number shows where in the standard library it did originate.
 
B

bilsch

Possibly, an exception was thrown from the standard library and
the line number shows where in the standard library it did originate.
Do you think it could be due to a virus? I'm running Linux Ubuntu - the
linux heads all say there's no anti-virus programs for linux.
 
R

Roedy Green

Do you think it could be due to a virus? I'm running Linux Ubuntu - the
linux heads all say there's no anti-virus programs for linux.

Viruses are blamed all the time for errors the user made and bugs in
the OS. When you are programming it is nearly always your own fault.

If you get a stack trace, look for the line in your own program not
ones in the standard library.

If you get a mysterious compiler error see
http://mindprod.com/jgloss/compilererrormessages.html

If you are seeking help, you need to list the program and the compiler
error message and indicate where in the program each error message is
pointing.

Try compiling without an IDE using just JavaC in case the problem is
misunderstanding how to use the IDE.
see http://mindprod.com/jgloss/javacexe.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML.
They forget that the simplest language is the one you
already know. They also forget that their simple little
markup language will bit by bit become even more convoluted
and complicated than HTML because of the unplanned way it grows.
..
 
J

Joshua Cranmer

I wrote a loop to read a 26000 character text file NVRAM.TXT into a
character array. It worked fine. The program is listed below. It has
only 24 lines. Today when I run it, it has weird errors referenced to
line numbers 2442, 2685 and 1620. When I click on those error messages
it shows lines in a completely different program - a program that I
never wrote for sure. I saved the file with a different name and it runs
fine with that name - no errors. The file name that has the problem is
Nvj5. That is the file selected and displayed when I click RUN FILE. It
is the file listed below. Even though it is selected and displayed when
I click RUN FILE my system is running some other huge file instead. Has
anyone ever heard of a problem like this?

When you refuse to mention error messages, the answer becomes "I have no
clue."

It would also help to know what the command line is that is causing it.
It could be that your IDE is buggy, too (since it sounds like you rely
on a specific IDE feature).
 
B

bilsch

When you refuse to mention error messages, the answer becomes "I have no
clue."

It would also help to know what the command line is that is causing it.
It could be that your IDE is buggy, too (since it sounds like you rely
on a specific IDE feature).
I can't tell you the error messages now because I deleted the offending
file - so can't generate errors anymore. It seems the error messages
are irrelevant since they point to lines in some large unknown program.
 
A

Arved Sandstrom

I can't tell you the error messages now because I deleted the offending
file - so can't generate errors anymore. It seems the error messages
are irrelevant since they point to lines in some large unknown program.

Your system is not "running" some other "file", not in the sense that
you think. Your Java source files are compiled into .class files, these
are loaded up into memory as required, and broadly speaking it's the
bytecodes in these class files that get executed ("run"). The first
application code to execute is the proper main() method in your main
class...like Nvj5.main(). Since you are using standard library code
also, like FileInputStream, code in those classes - and in the classes
that FileInputStream uses, and so on and so on - also gets executed.

That mysterious huge file is a standard library class that your code
needs to work. It's not irrelevant. A high percentage of the time when
you write buggy code the errors start in library code, not in your own
code. You need to look at the entire stack. You will notice that
somewhere in the stack are line references to your own code also.

You deleted and renamed *which* files exactly? Also, you have a class
Nvj5 but a corresponding source file "Nvj5.java". You'll find that
people understand you better if you differentiate between data files
(like NVRAM.TXT) and source files (like Nvj5.java).

Are you saying that you renamed class Nvj5 in source file Nvj5.java to
class Pwll12 in source file Pwll12.java, say, and ever since your
program has run like a charm? That seems highly unlikely. In fact that's
astronomically unlikely.

What IDE or programming text editor are you using? How many "main"
classes are currently available in your workspace? When you tried that
failing run did you see any console output at all?

AHS
 
B

bilsch

Your system is not "running" some other "file", not in the sense that
you think. Your Java source files are compiled into .class files, these
are loaded up into memory as required, and broadly speaking it's the
bytecodes in these class files that get executed ("run"). The first
application code to execute is the proper main() method in your main
class...like Nvj5.main(). Since you are using standard library code
also, like FileInputStream, code in those classes - and in the classes
that FileInputStream uses, and so on and so on - also gets executed.

That mysterious huge file is a standard library class that your code
needs to work. It's not irrelevant. A high percentage of the time when
you write buggy code the errors start in library code, not in your own
code. You need to look at the entire stack. You will notice that
somewhere in the stack are line references to your own code also.

You deleted and renamed *which* files exactly? Also, you have a class
Nvj5 but a corresponding source file "Nvj5.java". You'll find that
people understand you better if you differentiate between data files
(like NVRAM.TXT) and source files (like Nvj5.java).

Are you saying that you renamed class Nvj5 in source file Nvj5.java to
class Pwll12 in source file Pwll12.java, say, and ever since your
program has run like a charm? That seems highly unlikely. In fact that's
astronomically unlikely.
I copied the source from the offending file then I deleted the entire
project folder - everything. Then I created a new project and a new
blank .java file and pasted the copied source in that new file. I used
new names for the new file and folder. Once I did that the source(in
the new file) ran without a glitch. I tested it several times over a
period of days and it always worked. NOW, TODAY THE NEW FILE HAS GOTTEN
THE SAME PROBLEM JUST LIKE THE OLD FILE I have the error information
pasted below along with the source, also below. The error lines are in a
different file than the one I am running - now named Nvr1.java..
What IDE or programming text editor are you using? How many "main"
classes are currently available in your workspace? When you tried that
failing run did you see any console output at all?
I am using NetBeans to do exerything.

THE ERROR INFORMATION:
run:
Exception in thread "main" java.lang.VerifyError: Constructor must call
super() or this() before return in method Nvr1.<init>()V at offset 0
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:488)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
Java Result: 1
BUILD SUCCESSFUL (total time: 4 seconds)


THE SOURCE:
import java.io.*;

public class Nvr1 {

public static void main(String[] args){

try {
FileInputStream file = new FileInputStream("NVRAM.TXT");
char[] nvchr = new char [30000];
int fin = 1;
int count = 1;
while (fin != -1) {
fin = file.read();
nvchr[count] = (char) fin;
System.out.print(nvchr[count]);
count++;
}
System.out.println("Bytes read : " + count);
file.close();
} catch (IOException e){
System.out.println("Could not read file");
}

}
}

TIA. Bill S.
 
L

Lew

bilsch said:
.. . .
I copied the source from the offending file then I deleted the entire
project folder - everything. Then I created a new project and a new
blank .java file and pasted the copied source in that new file. I used
new names for the new file and folder. Once I did that the source(in
the new file) ran without a glitch. I tested it several times over a
period of days and it always worked. NOW, TODAY THE NEW FILE HAS GOTTEN
THE SAME PROBLEM JUST LIKE THE OLD FILE I have the error information

What do you mean by "FILE", exactly?

Files don't execute in Java.
pasted below along with the source, also below. The error lines are in a
different file than the one I am running - now named Nvr1.java..

The error message clearly states, "method Nvr1.<init>()V". That is definitely in your class. It is, in fact, the initializer of your class.

How do you conclude otherwise?
THE ERROR INFORMATION:
run:
Exception in thread "main" java.lang.VerifyError: Constructor must call
super() or this() before return in method Nvr1.<init>()V at offset 0
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:488)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480)
Java Result: 1
BUILD SUCCESSFUL (total time: 4 seconds)


THE SOURCE:
import java.io.*;

public class Nvr1 {

public static void main(String[] args){

try {
FileInputStream file = new FileInputStream("NVRAM.TXT");
char[] nvchr = new char [30000];
int fin = 1;
int count = 1;
while (fin != -1) {
fin = file.read();
nvchr[count] = (char) fin;

Why aren't you using the first element of the array?
System.out.print(nvchr[count]);
count++;
}

What happens if 'count' equals '30000'?
System.out.println("Bytes read : " + count);
file.close();
} catch (IOException e){
System.out.println("Could not read file");
}

}
}

The problem, based on what we've seen here, might be in the way the command is invoked. It depends on being run from the correct directory with all the right libraries in its classpath. If those conditions don't hold, you could get weird results.

That said, the error message doesn't jibe well with what we're seeing. You don't call any constructors, so it's odd the error message refers to constructors.

What happens (i.e., copy and paste the output) when you run the program from the command line?
 
A

Arved Sandstrom

On 12-05-03 08:05 PM, Lew wrote:
[ SNIP ]
That said, the error message doesn't jibe well with what we're seeing. You don't call any constructors, so it's odd the error message refers to constructors.
[ SNIP ]

It doesn't jibe, no. OTOH, a search on the VerifyError message +
"NetBeans" does turn up indications that NB exhibits this error in
several situations. Often solved, just as with Eclipse in umpteen
circumstances, with the classic "Clean-Rebuild-Try Again-Curse-Repeat"
cycle.

I wouldn't rule out that there is NetBeans badness here. I figure most
of us have encountered situations where you open up an IDE on a project,
where the day before everything was OK, and now suddenly it's seriously
out of whack.

Your suggestion to have the OP try the build and run on the command line
is a great idea. I strongly second that.

AHS
 
B

bilsch

On 12-05-03 08:05 PM, Lew wrote:
[ SNIP ]
That said, the error message doesn't jibe well with what we're seeing. You don't call any constructors, so it's odd the error message refers to constructors.
[ SNIP ]

It doesn't jibe, no. OTOH, a search on the VerifyError message +
"NetBeans" does turn up indications that NB exhibits this error in
several situations. Often solved, just as with Eclipse in umpteen
circumstances, with the classic "Clean-Rebuild-Try Again-Curse-Repeat"
cycle.

I wouldn't rule out that there is NetBeans badness here. I figure most
of us have encountered situations where you open up an IDE on a project,
where the day before everything was OK, and now suddenly it's seriously
out of whack.

Your suggestion to have the OP try the build and run on the command line
is a great idea. I strongly second that.

AHS

Programs java and javac are in directory: /home/bilsch/jdk7/bin/
Offending program, Nvr1.java is in directory:

/home/bilsch/NetBeansProjects/NVRAM/src/

environment variable PATH is:

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

However note that when I run; java Nvr1.class (or simply Nvr1) from my
home directory the output errors are in javanese, as follows:

bilsch@p4pwj:~/jdk7/bin$ java Nvr1
Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1
Caused by: java.lang.ClassNotFoundException: Nvr1
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Nvr1. Program will exit.
bilsch@p4pwj:~/jdk7/bin$ cd
bilsch@p4pwj:~$ java Nvr1.class
Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1/class
Caused by: java.lang.ClassNotFoundException: Nvr1.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

Could not find the main class: Nvr1.class. Program will exit.

Therefore the command line is hooked up with the java directory -
regardless of the PATH.

When I change working directory to /home/bilsch/jdk7/bin/ and type in
the path and filename for the offending file I get the following output:

bilsch@p4pwj:~/jdk7/bin$ javac /NetBeansProjects/NVRAM/src/Nvr1

The program 'javac' can be found in the following packages:
* openjdk-6-jdk
* ecj
* gcj-4.4-jdk
* gcj-4.6-jdk
* gcj-4.5-jdk
* openjdk-7-jdk
Try: sudo apt-get install <selected package>
bilsch@p4pwj:~/jdk7/bin$
bilsch@p4pwj:~/jdk7/bin$

Ubuntu can't find javac even though I ran it from the directory where
javac resides. It can't find it from the home directory either.

THE SHORT ANSWER IS I CAN'T COMPILE OR RUN JAVA FROM MY LINUX COMMAND
LINE. I can't answer your question of what the output is when running
command line. Also I have no idea why Linux won't do it. I'LL HAVE TO
WORK ON THAT.

I have to figure how to run from command line in linux. If I could run
using Windows command line and it worked that would be inconclusive ie.
taking Linux out of the equation. If I could run it in Windows command
line tonight and it worked OK that wouldn't mean it would still work 4
days from now?

This could be a Linux glitch rather than Java.

Thanks for listening. Bill S.
 
L

Lew

bilsch said:
Programs java and javac are in directory: /home/bilsch/jdk7/bin/
Offending program, Nvr1.java is in directory:

/home/bilsch/NetBeansProjects/NVRAM/src/

environment variable PATH is:

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

However note that when I run; java Nvr1.class (or simply Nvr1) from my
home directory the output errors are in javanese, as follows:

bilsch@p4pwj:~/jdk7/bin$ java Nvr1
Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1
Caused by: java.lang.ClassNotFoundException: Nvr1
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Nvr1. Program will exit.
bilsch@p4pwj:~/jdk7/bin$ cd
bilsch@p4pwj:~$ java Nvr1.class
Exception in thread "main" java.lang.NoClassDefFoundError: Nvr1/class
Caused by: java.lang.ClassNotFoundException: Nvr1.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

Could not find the main class: Nvr1.class. Program will exit.

Therefore the command line is hooked up with the java directory -
regardless of the PATH.

Huh?

Besides that I'm not sure what you mean by "the command line is hooked up with the java directory", there is no reason to associate the PATH envar with the error you show, which is simply due to the fact that you did not specify the classpath correctly. Or at all. And tried to run the Java program from a directory such that the default classpath does not include it.

When I change working directory to /home/bilsch/jdk7/bin/ and type in
the path and filename for the offending file I get the following output:

bilsch@p4pwj:~/jdk7/bin$ javac /NetBeansProjects/NVRAM/src/Nvr1

The program 'javac' can be found in the following packages:
* openjdk-6-jdk
* ecj
* gcj-4.4-jdk
* gcj-4.6-jdk
* gcj-4.5-jdk
* openjdk-7-jdk
Try: sudo apt-get install <selected package>
bilsch@p4pwj:~/jdk7/bin$
bilsch@p4pwj:~/jdk7/bin$

Ubuntu can't find javac even though I ran it from the directory where
javac resides. It can't find it from the home directory either.

THE SHORT ANSWER IS I CAN'T COMPILE OR RUN JAVA FROM MY LINUX COMMAND
LINE. I can't answer your question of what the output is when running
Shh.

command line. Also I have no idea why Linux won't do it. I'LL HAVE TO
WORK ON THAT.

Shh.

You showed us the output. Why do you say you can't answer the question thatyou just answered?
I have to figure how to run from command line in linux. If I could run

You could try reading the documentation for the "java" command.

Try this:

$ java -cp ${directory_where_the_class_file_is} Nvr1
using Windows command line and it worked that would be inconclusive ie.
taking Linux out of the equation. If I could run it in Windows command
line tonight and it worked OK that wouldn't mean it would still work 4
days from now?

If you were to specify the command line correctly, it would work right now,in Linux.
This could be a Linux glitch rather than Java.

No, it's operator error.

Neither Linux nor Java is at fault.

You need to read the documentation for the commands you're using, is all.

Had you done so, you'd've known up front that "java Nvr1.class" is wrong always, and why your attempt to run "java Nvr1" without a matching classpath failed.

Which it would do in the same way in Windows for the same reason.

RTFM.
 
A

Andreas Leitgeb

bilsch said:
environment variable PATH is:
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
bilsch@p4pwj:~/jdk7/bin$ java Nvr1

You don't have "." or ~/jdk7/bin in your PATH. So it probably has
picked up some system-installed java from /usr/bin

Add the bin directory of your jdk7 to the beginning of your PATH,
and some of your obstacles might dissolve.

Anyway, your Nvr1.class file surely isn't in ~/jdk7/bin, so the
Could not find the main class: Nvr1. Program will exit.
was to be expected.
bilsch@p4pwj:~/jdk7/bin$ javac /NetBeansProjects/NVRAM/src/Nvr1
The program 'javac' can be found in the following packages:

That's a shell-convenience, and it seems like you have a jre
installed system-wide, but not a jdk.

To actually use your priovate jdk7 installation, you have to
add it to your PATH (and before /usr/bin)

Your PATH probably should look like:
/home/bilsch/jdk7/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

(I'm speculating about your actual home-directory here)
 
B

bilsch

And there's your problem -- your PATH does not contain the directory
your java and javac commands are found in, neither as an explicit
entry of /home/bilsch/jdk7/bin/ or implicitly through the current
directory .


You're running a java command here, but not the one at
/home/bilsch/jdk7/bin/java -- you must have another java command in
your system somewhere. (Try the command "which java" to show where
the java command that's actually being run is.)

The solution is to add the directory /home/bilsch/jdk7/bin/ to the
front of your PATH. Write the following command on the command line:

export PATH=/home/bilsch/jdk7/bin/:$PATH

You should then be able to call javac, use that to create a .class
file and then use java to run the class file.

I added /home/bilsch/jdk7/bin to PATH and was able to both compile and
run program Nvr1 from the command line. Also, when I then go into
NetBeans and run the file it works without errors. HOWEVER, AFTER I RUN
IN NETBEANS MY PATH STATEMENT REVERTS TO THE ORIGINAL VERSION ie. the
/home/bilsch/jdk7/bin part has been removed. I even put the PATH change
in two different places in the PATH variable and both were removed. Does
anybody have a java IDE other than NetBeans ?

Also, a pain in the ass is I must change directory to where the source
file resides to compile. I must change directory to where the .class
file resides in order to run. These directories are different for every
project therefore it's not practical to automate with a script.

Bill S.
 
M

Martin Gregorie

I added /home/bilsch/jdk7/bin to PATH and was able to both compile and
run program Nvr1 from the command line. Also, when I then go into
NetBeans and run the file it works without errors. HOWEVER, AFTER I RUN
IN NETBEANS MY PATH STATEMENT REVERTS TO THE ORIGINAL VERSION ie. the
/home/bilsch/jdk7/bin part has been removed. I even put the PATH change
in two different places in the PATH variable and both were removed. Does
anybody have a java IDE other than NetBeans ?
Look at where PATH is defined in the NetBeans configuration and change
that.
Also, a pain in the ass is I must change directory to where the source
file resides to compile. I must change directory to where the .class
file resides in order to run. These directories are different for every
project therefore it's not practical to automate with a script.
Either use Ant (write a build.xml file if you can't use the one that
NetBeans uses) and/or write a shell script to run the compile from the
correct directory.
 
L

Lew

bilsch said:
Also, a pain in the ass is I must change directory to where the source
file resides to compile. I must change directory to where the .class
file resides in order to run. These directories are different for every
project therefore it's not practical to automate with a script.

That is totally untrue.

Both the compiler ("javac") and the runtime ("java") respect classpaths,
and the latter respects source paths. With those, you can compile and run
Java code from any directory regardless of your current directory.

Please, please, please, please, *please* RTFM!

Especially before you start ranting incorrectly about what is not possible.

Why did you ignore the earlier advice to do that?
 
M

Martin Gregorie

This isn't a problem with NetBeans, but has to do with how environment
variables work. An "export" statement only sets an environment variable
for the current shell. To have the change stick, you need to put the
addition to PATH in a configuration file (most likely ~/.profile, but
some linux distroes can be a little weird about it) so that it will be
set for every shell you open.
In the Redhat family of distros you can make this sort of change by
putting a script in /etc/profile.d

Scripts in profile.d are run after /etc/profile so I have one called
java.sh which sets all my Java-related environment variables, e.g.
JAVA_HOME, ANT_HOME and uses the pathmunge shell function to add /usr/
java/sdk/bin and /usr/java/ant/bin to $PATH

I make a lot of use symlinks: /usr/java is a symlink to /home/java so my
Java set-up will survive a system reinstall. /home is in a separate
partition that isn't reformatted during an install.

Inside the /home/java directory, jdk is a symlink to the current Java SDK
install and ant is a symlink to the current Ant install. This means that
the contents of /etc/profile.d/java.sh doesn't change when I install a
new version of the JDK: I merely switch the sdk symlink at the same time
as I unpack the download.
You don't have to do either of these. I suggest you follow Lew's
suggestion and read the documentation for the java and javac commands.
Seconded.
If you take the time to set your system up appropriately everything will
'just work'.
 
B

bilsch

Look at where PATH is defined in the NetBeans configuration and change
that.
I can't find any place where path is defined in NetBeans. They told me
two ways to change PATH outside of NetBeans. I did that.
Either use Ant (write a build.xml file if you can't use the one that
NetBeans uses) and/or write a shell script to run the compile from the
correct directory.

I have an ANT directory and a tab for it in NetBeans but I dont know if
it is installed. Same goes for Maven. I tried starting it on the
command line ant there it says to install it.
 
B

bilsch

Look at where PATH is defined in the NetBeans configuration and change
that.

Either use Ant (write a build.xml file if you can't use the one that
NetBeans uses) and/or write a shell script to run the compile from the
correct directory.
I'm not too handy with shell programming.
 
B

bilsch

In the Redhat family of distros you can make this sort of change by
putting a script in /etc/profile.d

Scripts in profile.d are run after /etc/profile so I have one called
java.sh which sets all my Java-related environment variables, e.g.
JAVA_HOME, ANT_HOME and uses the pathmunge shell function to add /usr/
java/sdk/bin and /usr/java/ant/bin to $PATH

I make a lot of use symlinks: /usr/java is a symlink to /home/java so my
Java set-up will survive a system reinstall. /home is in a separate
partition that isn't reformatted during an install.

Inside the /home/java directory, jdk is a symlink to the current Java SDK
install and ant is a symlink to the current Ant install. This means that
the contents of /etc/profile.d/java.sh doesn't change when I install a
new version of the JDK: I merely switch the sdk symlink at the same time
as I unpack the download.

It is interesting and I grasp the concepts but actually doing those
things myself is beyond me.
Seconded.
I can't find any documentation for command line java and javac.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top