Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi everyone...i was wondering if there was a simple compiling command to compile and run java code on redhat 8. i installed all the development packages durring installation. i know that gcc has ability to compile java but i read that it might not be the best. also i know i can go and download jre from sun, but is it already installed, and if so how do i utalize it. may be a dumb question, but i am working in trying to become ms free, so if there is an easier way for some task, i would love to know. thanks again.

first check, if the classpath and path variables are set to the correct directories for java.
second: comiling java - type in "javac [file.java]" - you get a file like [file.class] or error messages cuz of wrong code.
third: executing java prog - type in "java [file]" the program should start. Pls take care of the cases. Java is case sensitive. also, you donot need to add the suffix to the file name. Just the name of your class is enough for java class loader.
stay safe
thomas

Alright that sounds good. However, How do I set the class path and path directories. I am getting the error
Exception in thread "main" java.lang.NoClassDefFoundError: /root/test
I am pretty sure this is due to the class path. Just in case here is the code of my test.java. thanks again though this is alot furthuer then I was getting before.
public class test
{
public static void main(String[] arguments)
{
System.out.println("Work Please");
}
}

are you in the directory of where your java code when you do the "javac test.java" command...
also you can just use "args" for "arguments".
java is fun just keep on messing around with the terminal javac binary
also i really like net beans as an ide. it is not that hard to set up... and it has a lot of neat auto fill in features...

Hi,
I am still a beginner at Java but I hope I can assist. Your program/code read:
public class test
{
public static void main(String[] arguments)
{
System.out.println("Work Please");
}
}I noted the following:
1. The name of the program/class must always start with a Capital letter. i.e. change you first line to:
public class Test
2. The line on which you declare your main method has something that I am not sure is correct (i.e. arguments instead of args), could you try:
public static void main(String[] args)
3. To compile, if you cannot set the path, you actually do not need to. I always compile with the following: \java\bin\javac file.java (in MS) but I think (in Linux) you can try
/java/bin/javac Test.java (Remember Java is case sensitive!)
and to run may be:
/java/bin/java Test
Regards
Stephen

Sorry,
I am making a correction about my earlier suggestion. I used /Java/ hoping that it is the folder in which you installed the JAVA SDK but usually if you don't specify, then it is usually installed in /j2sdk1.4.1.
SETTING THE PATH (From Lawrence)
Assuming that it is in /usr/bin/j2sdk1.4.1, then add these two lines in either /etc/bashrc or /etc/profile
PATH=$PATH:/usr/bin/j2sdk1.4.1/bin
export PATHBest rgds
Kisuze

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |