Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How Do I Publish My Working Project (corresponding dot jar doesn'twork on other's PCs)

Reply
Thread Tools

How Do I Publish My Working Project (corresponding dot jar doesn'twork on other's PCs)

 
 
markspace
Guest
Posts: n/a
 
      09-11-2012
On 9/11/2012 5:12 AM, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> On NetBeans, how do I determine what JDK I'm using. I forgot which
> one I loaded.



It's in your project properties. And it's not the one you have loaded,
it's the one you have set for the build target. In other words, if you
are using JDK 7, you can still be targeting for example Java 5 in your
project, which is useful if you have users still on Java 5 who don't
want to upgrade.

Right-click on the project, Properties -> Sources, way down at the
bottom it says "Sources/Binary Format", that's your target (I'm using NB
7.2 btw, I seem to remember a slightly different option format in NB 6).

Also, you need the JRE. The JDK is for development, your users won't
normally need that. All they need is the normal runtime, the JRE. You
personally can use the JDK, because it contains a JRE, but anyone else
will normally just have the JRE.

To run, you use java -cp <path to all needed jars> -jar <path/your jar>

If you need to do fancier things than that (distribute over the
internet, for example) then look into Java WebStart or consider OneJar
if you are going to just copy the files around.


 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      09-11-2012
markspace wrote:
> To run, you use java -cp <path to all needed jars> -jar <path/your jar>


The problem with that is that the command will ignore the "-cp" parameter.

"-cp" and "-jar" is either/or proposition.

--
Lew
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      09-11-2012
On 9/11/2012 11:08 AM, Lew wrote:
> markspace wrote:
>> To run, you use java -cp <path to all needed jars> -jar <path/your jar>

>
> The problem with that is that the command will ignore the "-cp" parameter.
>
> "-cp" and "-jar" is either/or proposition.
>



Yes I totally forgot about that. I guess I don't actually run java from
the command line very often.

That leaves setting the classpath in the jar itself, which is kind of
tricky if you are going to be moving the jar to other people's
computers. Java WebStart and OneJar come in handy here.

Classpath in a jarfile:

<http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html>



 
Reply With Quote
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      09-11-2012
On Tuesday, September 11, 2012 12:25:45 PM UTC-4, markspace wrote:
> On 9/11/2012 5:12 AM, ... wrote: > On NetBeans, how do I determine what JDK I'm using. I forgot which > one I loaded. It's in your project properties. And it's not the one you have loaded, it's the one you have set for the build target. In other words, if you are using JDK 7, you can still be targeting for example Java 5 in your project, which is useful if you have usersstill on Java 5 who don't want to upgrade. Right-click on the project, Properties -> Sources, way down at the bottom it says "Sources/Binary Format",that's your target (I'm using NB 7.2 btw, I seem to remember a slightly different option format in NB 6). Also, you need the JRE. The JDK is for development, your users won't normally need that. All they need is the normal runtime, the JRE. You personally can use the JDK, because it contains a JRE,but anyone else will normally just have the JRE. To run, you use java -cp <path to all needed jars> -jar <path/your jar> If you need to do fancier things than that (distribute over the internet, for example) then look into Java WebStart or consider OneJar if you are going to just copy the files around.


How do I determine the specific JRE that I need.

Thanks,
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      09-12-2012
On 9/11/2012 4:21 PM, (E-Mail Removed) wrote:

> On Tuesday, September 11, 2012 12:25:45 PM UTC-4, markspace wrote:


>> Right-click on the project, Properties ->
>> Sources, way down at the bottom it says "Sources/Binary Format",
>> that's your target


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^

> How do I determine the specific JRE that I need.



Reading the replies you get on this newsgroup would be a good start.


 
Reply With Quote
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      09-12-2012
On Tuesday, September 11, 2012 3:45:42 PM UTC-4, markspace wrote:
> On 9/11/2012 11:08 AM, Lew wrote: > markspace wrote:
> That leaves setting the classpath in the jar itself, which is kind of tricky if
> you are going to be moving the jar to other people's computers. Java WebStart
> and OneJar come in handy here. Classpath in a jarfile:
> <http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html>


I just saw this article on the Internet. My guess is I should ignore this article, right?

http://ac-support.europe.umuc.edu/~a...Classpath.html

Thanks,
 
Reply With Quote
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      09-12-2012
> On Wednesday, September 12, 2012 10:24:20 AM UTC-4, (unknown) wrote:
>> On Tuesday, September 11, 2012 3:45:42 PM UTC-4, markspace wrote:
>> On 9/11/2012 11:08 AM, Lew wrote:
>> markspace wrote:
>> That leaves setting the classpath in the jar itself, which is kind of tricky if
>> you are going to be moving the jar to other people's computers. Java WebStart
>> and OneJar come in handy here. Classpath in a jarfile:
>> <http://docs.oracle.com/javase/tutori...r/downman.html
>> I just saw this article on the Internet. My guess is I should ignore this
>> article, right? http://ac-
>> support.europe.umuc.edu/~arnoldyl/NetBeansTutorials/Setting-Classpath.html


I added the path to all my dot jars into an environment variable (user varianble and not a system variable) called classpath and was unable to run the project. I mean nothing happened.

Via the Control Panel, I have the following programs installed on my friend's computer:

Java 7 Update 7
Java SE Development Kit 7 Update 7
Java(TM) 6 Update 34
Java(TM) 6 Update 34 (64-bit)

What's up? What do I do.

Thank you,
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      09-12-2012
On 9/12/2012 8:00 AM, (E-Mail Removed) wrote:

>>>

> I added the path to all my dot jars into an environment variable
> (user varianble and not a system variable) called classpath and was
> unable to run the project. I mean nothing happened.
>


Learn to debug. Add some print statements so you can trace the
execution of your program. Attach a debugger.

If nothing happens, that's because your app did nothing. Java will
print an error message if it finds a problem.


 
Reply With Quote
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      09-12-2012
>On Wednesday, September 12, 2012 11:21:45 AM UTC-4, markspace wrote:
>> On 9/12/2012 8:00 AM, ... wrote:
>> I added the path to all my dot jars into an environment variable
>> (user varianble and not a system variable) called classpath and was
>> unable to run the project. I mean nothing happened.

>
> Learn to debug. Add some print statements so you can trace the execution of
> your program. Attach a debugger. If nothing happens, that's because your app
> did nothing. Java will print an error message if it finds a problem.


I added the following as the first executable statement (etc) in the project:

System.out.println("Hello 1");

I then ran the project on my friend's PC using the Command Prompt and the command: java testing.jar

I received the error message:

Exception in thread "main" java.lang.NoClassDefFoundError: testing/jar
Caused by: java.lang.ClassNotFoundException: testing.jar
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: testing.jar. Program will exit.

Thank you,
 
Reply With Quote
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      09-12-2012
On my own PC under NetBeans, I have no problem. I see the following from five print statements!

init:
Deleting: C:\testing\build\built-jar.properties
deps-jar:
Updating property file: C:\testing\build\built-jar.properties
files are up to date
compile:
run:
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
BUILD SUCCESSFUL (total time: 19 seconds)

Thank you,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Dot Net Project Execution without Dot Net and Framework.... krishnan ASP .Net Building Controls 0 01-07-2006 08:51 AM
Dynamically resize visible text and append dot dot dot (like gmail subject lines.. ) how to question? jawolter@gmail.com Javascript 6 12-12-2005 04:09 PM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM



Advertisments