11 Replies - 3739 Views - Last Post: 02 May 2011 - 08:55 AM Rate Topic: -----

#1 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

How to start the java code at computer start-up

Posted 30 April 2011 - 12:22 PM

Hi

I have written a lot of code that allow me to start some programs. To give an idea of what I'm talking about,
here is a small piece of code:
public void openFile(File file) throws IOException{
		desktop.open(file);
	}

public void openUrl(URI uri) throws IOException, URISyntaxException{
		desktop.open(uri)
        }



I used JFrame to create the GUI.
The thing now is that I want this little GUI to start up by itself when I turn on my computer, instead of me having to open the command prompt, and call the main method etc. (Just like MSN, Skype etc. start up automatically).

It's just that I have no idea what to search/google for. Is there a specific java class that allows this?
Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: How to start the java code at computer start-up

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10447
  • View blog
  • Posts: 38,690
  • Joined: 27-December 08

Re: How to start the java code at computer start-up

Posted 30 April 2011 - 01:02 PM

If you want to start a program when the computer is booted up, take a look at something like a batch file, depending on your OS. There are also task scheduling programs you can download. There really isn't anything you can do on the Java end, though, as in order for Java programs to run, the JVM must first be initialized.
Was This Post Helpful? 1
  • +
  • -

#3 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: How to start the java code at computer start-up

Posted 30 April 2011 - 03:21 PM

Is it possible to run the sofware you make in java in other ways than opening a prompt, and type to call the main method? Like can something be done such that I can start a java program from a mouse-click or so? Like having the sofware in the start menu, and then just click on it to run it?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10447
  • View blog
  • Posts: 38,690
  • Joined: 27-December 08

Re: How to start the java code at computer start-up

Posted 30 April 2011 - 03:22 PM

Take a look at deploying a JAR file.
Was This Post Helpful? 1
  • +
  • -

#5 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: How to start the java code at computer start-up

Posted 30 April 2011 - 03:29 PM

If only Windows had a menu of all the programs you could launch, or maybe the ability to put program launch icons on the main screen...

Anyway, what I recommend if you're using Windows is to make a jar file for your Java application, make a shortcut for it and put the shortcut in the startup folder in your start menu. Putting the jar file directly into the startup folder would probably work as well.
Was This Post Helpful? 0
  • +
  • -

#6 supercorey  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 119
  • View blog
  • Posts: 207
  • Joined: 15-February 09

Re: How to start the java code at computer start-up

Posted 30 April 2011 - 06:23 PM

It's all OS specific. What works for Windows will not work for Mac OS X, Linux, etc. If you are using Windows (XP at least, not sure about later or earlier ones), there is a start-up script. No clue about Mac OS X since I've never used it. As for Linux, I believe it differs from distro to distro. Ubuntu has the ability to do it. For some Linux distros, it can also be set through the GNOME GUI (if existant). Effectively, there isn't any internal way to do this with Java as far as I am aware.
Was This Post Helpful? 0
  • +
  • -

#7 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: How to start the java code at computer start-up

Posted 01 May 2011 - 01:55 AM

View Postsupercorey, on 30 April 2011 - 06:23 PM, said:

It's all OS specific. What works for Windows will not work for Mac OS X, Linux, etc. If you are using Windows (XP at least, not sure about later or earlier ones), there is a start-up script. No clue about Mac OS X since I've never used it. As for Linux, I believe it differs from distro to distro. Ubuntu has the ability to do it. For some Linux distros, it can also be set through the GNOME GUI (if existant). Effectively, there isn't any internal way to do this with Java as far as I am aware.


I guess it's some silly things I asked about. I thought maybe there was some easy stuff to do about it.

I am using Windows 7. Do you happen to know what those scrips are called?
Was This Post Helpful? 0
  • +
  • -

#8 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1949
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: How to start the java code at computer start-up

Posted 01 May 2011 - 02:34 AM

did my method not work? It's quick and easy.
Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

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

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

Re: How to start the java code at computer start-up

Posted 01 May 2011 - 03:22 AM

View PostIamTw_, on 01 May 2011 - 03:55 AM, said:

I am using Windows 7. Do you happen to know what those scrips are called?

Just add a .bat file that > java TheClassYouWant
in the startup what ever it is called
Was This Post Helpful? 0
  • +
  • -

#10 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2676
  • View blog
  • Posts: 11,309
  • Joined: 20-September 08

Re: How to start the java code at computer start-up

Posted 01 May 2011 - 03:46 AM

You might want to use a SystemTray icon: http://download.orac...SystemTray.html

You should be able to simply drag the executable jar into the Windows Startup folder
Was This Post Helpful? 0
  • +
  • -

#11 supercorey  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 119
  • View blog
  • Posts: 207
  • Joined: 15-February 09

Re: How to start the java code at computer start-up

Posted 01 May 2011 - 06:27 AM

I just noticed that I misread cfoley's post. I basically said the same thing. That is the quickest and simplest method, in my and many others' opinions. For Windows 7, instructions to do it that way are explained quickly and simply here:
http://www.ehow.com/...-windows-7.html

EDIT:g00se said it too.

This post has been edited by supercorey: 01 May 2011 - 06:28 AM

Was This Post Helpful? 2
  • +
  • -

#12 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: How to start the java code at computer start-up

Posted 02 May 2011 - 08:55 AM

View PostIamTw_, on 30 April 2011 - 12:22 PM, said:

Hi

I have written a lot of code that allow me to start some programs. To give an idea of what I'm talking about,
here is a small piece of code:
public void openFile(File file) throws IOException{
		desktop.open(file);
	}

public void openUrl(URI uri) throws IOException, URISyntaxException{
		desktop.open(uri)
        }



I used JFrame to create the GUI.
The thing now is that I want this little GUI to start up by itself when I turn on my computer, instead of me having to open the command prompt, and call the main method etc. (Just like MSN, Skype etc. start up automatically).

It's just that I have no idea what to search/google for. Is there a specific java class that allows this?
Thanks in advance.

Hi again all

I solved the problem to my early question. It turned out to be a really simple thing.
In case someone else should want to make their "little software" or what ever you would call it start up without having to start eclipse/IDE/compiler, or call the main method from a promt, I'll write the solution.

What I did was to create a runnable jar file, this is what you do in eclipse.

1. Go to file -> Export.
Now you will be asked to select an Export destination. Among the directories, you will see that java directory, select

2. Click on the java directory, and select "Runnable JAR file", then click next (Look carefully so you don't take the wrong one).
After you have clicked next, you will see a place saying "Lunch configuration" and you will see a little arrow.

3. Click on the little arrow to get a dropdown where you will see all your java projects. Now choose your program.

4. Now just below "Lunch configuration, you will see "Export destination". Choose your export destination and click finish.

5. You will now get a warning saying "JAR export finished with warnings. See details for information". This is nothing serious, you can read the details if you want. But once done click ok. Now you get a JAR file to the directory you chose. Click on that, and your program starts :)

6. You can also make it start up by itself when you turn on your computer. Instead of writing down what to do, I'll give the link that I used, http://www.ehow.com/...-windows-7.html
Thanks alot to supercorey for this link. Also thanks alot to g00se for this link:
http://download.orac...ystemTray.html.

Thanks to all you guys who have posted in this thread for trying to help.

I hope this is useful stuff, and will save you from all that time I spent on solving the problem.

This post has been edited by IamTw_: 02 May 2011 - 09:03 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1