AutoCompile Java programs

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 2190 Views - Last Post: 23 July 2010 - 02:32 PM Rate Topic: -----

#1 sh1n3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 164
  • Joined: 22-April 10

AutoCompile Java programs

Posted 16 July 2010 - 05:51 AM

Hi,
I'm fairly new to programming itself but as it is I'm very lazy or as I say it Time-Preserving. I try whatever I can to make creating, compiling and running programs faster. I do not know if this has ever been done but I have made my system in such a way that when I double-click on a java program i.e. *.java file it compiles and there is a *.class file in the same directory. Skipping the step where we usually open CMD.exe and compile it.

All I did was :
Goto Control Panel --> Folder Options --> File Types(Tab)

and click on new(button), it soon asks for the File Extension.

There type in JAVA, A File Extension named JAVA is created.

So select it and click on the Advanced(Button) and create a new Action.

Maybe give the name Compile and associate it with javac.exe in your bin folder.

It should look like this:
Action : Compile
Application used to perform Action : "C:\Java\JDK\bin\javac.exe" "%1"

Click The OK(Button) on both panes.


Now it should Autocompile when you double click on the JAVA file. I tried something similar with CLASS files but failed because It had no way to take the parameters.

Is This A Good Question/Topic? 0
  • +

Replies To: AutoCompile Java programs

#2 sh1n3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 164
  • Joined: 22-April 10

Re: AutoCompile Java programs

Posted 16 July 2010 - 05:57 AM

Oh I forgot you could also specify any Icon you'd want.
Was This Post Helpful? 0
  • +
  • -

#3 chirag.jain18  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 68
  • Joined: 14-December 09

Re: AutoCompile Java programs

Posted 16 July 2010 - 07:25 AM

Hi, I also tried the same thing. But I am not getting the .class file. Whwn I double click the file, the console window opens and closes immediately, and does not produce the .class file. What am I doing wrong here?
Was This Post Helpful? 0
  • +
  • -

#4 sh1n3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 164
  • Joined: 22-April 10

Re: AutoCompile Java programs

Posted 16 July 2010 - 07:36 AM

Have you added the "%1" next to the path "C:\java\javac.exe"?
"C:\java\javac.exe" "%1"

And please set the Compile action as Default action or else it will only show up in the Right Click Menu
Also sorry to inform now, but evidently it works on Windows and I'm running XP, so I don't know about other OSes

This post has been edited by sh1n3: 16 July 2010 - 10:19 AM

Was This Post Helpful? 0
  • +
  • -

#5 blixna_waka  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 60
  • Joined: 14-July 10

Re: AutoCompile Java programs

Posted 16 July 2010 - 07:38 AM

Although I'm not a Windows user(Linux FTW!), this tutorial could prove very useful to someone who isn't very skilled at command-line tasks(such as in this case, compiling a *.java file). Keep up the good work, and may the force be with you. (*starts dancing while waving hand in attempt to fool sh1n3*)
Was This Post Helpful? 0
  • +
  • -

#6 sh1n3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 164
  • Joined: 22-April 10

Re: AutoCompile Java programs

Posted 16 July 2010 - 07:44 AM

Well this is what I'd call an accidental discovery, maybe there's an equivalent in Linux. Maybe someone will find it.
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: AutoCompile Java programs

Posted 16 July 2010 - 04:13 PM

This is more a Windows question than a Java question
At your place, I would look into a Windows forum
I'll ask the tech support at the office Monday

This post has been edited by pbl: 16 July 2010 - 04:13 PM

Was This Post Helpful? 1
  • +
  • -

#8 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,027
  • Joined: 11-December 07

Re: AutoCompile Java programs

Posted 18 July 2010 - 06:54 PM

This approach could get nasty when you write programs with several classes in several files.
Was This Post Helpful? 1
  • +
  • -

#9 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: AutoCompile Java programs

Posted 18 July 2010 - 07:20 PM

View Postcfoley, on 18 July 2010 - 07:54 PM, said:

This approach could get nasty when you write programs with several classes in several files.

Jolly good point cfoley didn't thought of that one... you desserve a +1 for having noticed that one
Having a "double click" on a single file might not have the .class related to it compiled :)
Still will ask tomorrow but actually might be a poisonous gift but anyhow the techs at the office will be challenged by the assignment
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: AutoCompile Java programs

Posted 19 July 2010 - 05:33 PM

Sorry he is on vacations for the week
sh1n3 remember the thing to me next Monday
Was This Post Helpful? 0
  • +
  • -

#11 sh1n3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 164
  • Joined: 22-April 10

Re: AutoCompile Java programs

Posted 20 July 2010 - 05:46 PM

But I tried it out and all Inner classes also get compiled. I'm sure about it.
Was This Post Helpful? 0
  • +
  • -

#12 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,027
  • Joined: 11-December 07

Re: AutoCompile Java programs

Posted 20 July 2010 - 05:54 PM

I was going to recommend this as an ecample which would break that method.
Thought I'd try it first.

public class A {
    public B foo;
}

public class B {
    public A bar;
}


chris[test]$ geany A.java
chris[test]$ geany B.java
chris[test]$ javac A.java
chris[test]$


So that seemed to work. Strange.

Let's see what files are there.

chris[test]$ ls
A.class  A.java  B.class  B.java
chris[test]$


Both classes were compiled. Seems javac has been improved since I last played with it!
Was This Post Helpful? 0
  • +
  • -

#13 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: AutoCompile Java programs

Posted 20 July 2010 - 05:59 PM

View Postcfoley, on 20 July 2010 - 06:54 PM, said:

Both classes were compiled. Seems javac has been improved since I last played with it!

if the command executed is
> javac %dir%*.java
normal that it works
Was This Post Helpful? 0
  • +
  • -

#14 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,027
  • Joined: 11-December 07

Re: AutoCompile Java programs

Posted 20 July 2010 - 06:00 PM

Yeah, but I just did

javac A.java
Was This Post Helpful? 0
  • +
  • -

#15 sh1n3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 164
  • Joined: 22-April 10

Re: AutoCompile Java programs

Posted 20 July 2010 - 06:04 PM

Isn't that what everyone does, well I have been doing that since I started Swing last month, the Handler classes were automatically compiled when I compiled the main class.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2