• Post Reply Bookmark Topic Watch Topic
  • New Topic

how do i run java in svn linux terminal  RSS feed

 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a lot of Java file in the repository(svn add and commit), I know that javac is way to compile the java file but the problem is how do i run this Java file in the svn directory?
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would not have an svn directory as such. You would have the name of a project and you would download the .java files into a suitably named directory from the svn repository. How you compile them depends on whether you have multiple packages or not.
If you have everything in the unnamed package, as many people on this forum do, it is enough to pass
javac *.java
at a terminal.
If you have .java files in directories, you shou‍ld ensure the package declarations match the directory structure. Presumably you have previously compiled those files (or somebody else has), so the directory structure has probably been sorted out already. And any compiler errors corrected. Have a look for README or xyz.sh files; they may have compilation instructions in. Or you can remember how they files were compiled earlier.
Any classes which are dependencies for anything else shou‍ld be compiled first. If you need to compile class Foo in package foo, you will want
javac foo/Foo.java
at the terminal. If you haven't found an xyz.sh file, create your own. Copy'n'paste all compiler instructions which work into your own .sh file and add that to the repository for future reference; next time simply run the .sh file. If the instruction doesn't work, try a different class. Start as far from the class with the main method as possible and compile that class last.

Alternatively: open the entire contents as a project in an IDE and let the IDE do all the hard work.

Moving as too complicated a question for “Beginning”
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if I understand your question completely, but like Campbell said, javac *.java is how you compile and to run the program it's just 'java programName' at the terminal.
 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that make a lot of sense now. Just to make sure .sh file is a script shell that I need implemented the   make linux command or makefile in the .sh file
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jin Otanashi wrote:that make a lot of sense now. Just to make sure .sh file is a script shell that I need implemented the   make linux command or makefile in the .sh file


A .sh file can be a bash script file, but it is absolutely not related to Java as Java and Bash are two different languages. Shell scripting is different in Linux and to compile a shell script you need to make sure that you have executable access of that file in your permissions (chmod command allows you to modify permissions). Then you can execute that script with ./filename.sh
 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naziru Gelajo wrote:
jin Otanashi wrote:that make a lot of sense now. Just to make sure .sh file is a script shell that I need implemented the   make linux command or makefile in the .sh file


A .sh file can be a bash script file, but it is absolutely not related to Java as Java and Bash are two different languages. Shell scripting is different in Linux and to compile a shell script you need to make sure that you have executable access of that file in your permissions (chmod command allows you to modify permissions). Then you can execute that script with ./filename.sh

I see thank you for letting me know
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!